<template>
	<view class="container">
		<view class="user-wrapper fa">
			<view class="nav_top_left">
				<view class="top">
					<view class="nick_left" @click="goDetail('/pagesB/mine/userinfo/changeNickname?name='+userinfo.nickname)"  v-if="userinfo.id">{{userinfo.nickname}}</view>
					<view class="nick_left" @click="gologin()" v-else>去登录</view>
					
					
					<view class="nick_right" v-if="userinfo.type==0">
						<text v-if="lang==0">
							普通用户
						</text>
						<text v-if="lang==1">
							Ordinary users
						</text>
					</view>
					
					<view class="nick_right vip" v-if="userinfo.type==1">
						<text v-if="lang==0">
							VIP用户
						</text>
						<text v-if="lang==1">
							VIP users
						</text>
					</view>
					<view class="nick_right cj" v-if="userinfo.type==2">
						
						<text v-if="lang==0">
							厂家用户
						</text>
						<text v-if="lang==1">
							Manufacturer users
						</text>
					</view>
				</view>
				<view class="bottom" style="color: #fff;">
					<text v-if="lang==0">
						欢迎您使用  Vector 调控工具
					</text>
					<text v-if="lang==1">
							Welcome to use the Vector control tool
					</text>
					
				</view>
			</view>
			<view class="nav_top_right">
				<!-- <image class="avatar"  :src="userinfo.avatar ? userinfo.avatar : '/static/nologin.png'" mode="" @click="showActionSheet"></image> -->
				<image class="avatar"  :src="userinfo.avatar ? userinfo.avatar : '/static/nologin.png'" mode="" @click="$refs.actionSheetRef.open()"></image>
			</view>
		
				<image class="vip" src="../../../static/vip.png" mode="" v-if="userType == 2"></image>
				<!-- <view>{{userType == 2 ? '嘉宾' : '普通用户'}}</view> -->
		</view>
		
		<view class="guide fa jcsb">
			<view class="fa fdc" @click="goDetail('/pagesB/mine/index/guanfang')">
				<image src="../../../static/nav1.png" mode=""></image>
				<view>
					<text v-if="lang==0" style="color: #fff;">
						软件无限升级
					</text>
					<text v-if="lang==1" style="font-size:18rpx;color: #fff;">
						Upgradation
					</text>
				</view>
			</view>

			<view class="fa fdc" @click="baocun()">

				<image src="../../../static/nav2.png" mode=""></image>
				<view>
					<text v-if="lang==0" style="color: #fff;">
						保存参数
					</text>
					<text v-if="lang==1" style="font-size:18rpx;color: #fff;">
						Save parameters
					</text>
				</view>
			</view>

			<view class="fa fdc" @click="goDetail('/pagesB/mine/history/history')">
				<image src="../../../static/nav3.png" mode=""></image>
				<view>
					<text v-if="lang==0" style="color: #fff;">
						历史查询
					</text>
					<text v-if="lang==1" style="font-size:18rpx;color: #fff;">
						Historical query
					</text>
				</view>
			</view>
			<!-- <view class="fa fdc">
				<image src="../../../static/share2.png" mode=""></image>
				<view>我的收藏</view>
			</view> -->
		</view>
	
		<view class="lists">
			<view class="list fa jcsb" @click="lang_openPicker()">
				<view class="fa">
					<view>
						<text v-if="lang==0">
								语言切换
						</text>
						<text v-if="lang==1" >
							Language switching
						</text>
						
					</view>
				</view>
				<span class="rightimg_str">
					{{langList[0][lang]}}
				</span>
				
				<image class="rightimg" src="../../../static/rightimg.png" mode=""></image>
			</view>
			<view class="list fa jcsb" style="height: 1px !important;padding:0px;margin: 0rpx 20rpx 0;background: rgba(255, 255, 255, .3);;">
			
			</view>
			
			
			<view class="list fa jcsb" @click="goDetail('/pagesB/mine/index/controller-info')">
				<view class="fa">
					<text v-if="lang==0">
							控制器信息
					</text>
					<text v-if="lang==1">
						Controller information
					</text>
				</view>
				<image class="rightimg" src="../../../static/rightimg.png" mode=""></image>
			</view>
			<view class="list fa jcsb" style="height: 1px !important;padding:0px;margin: 0rpx 20rpx 0;background: rgba(255, 255, 255, .3);;">
			
			</view>
			
			<view class="list fa jcsb" >
				<view class="fa">
				
					<text v-if="lang==0">
							提取软件信息
					</text>
					<text v-if="lang==1">
						software information
					</text>
				</view>
				<span class="rightimg_str">
					xxxx
				</span>
			</view>
			
			<view class="list fa jcsb" style="height: 1px !important;padding:0px;margin: 0rpx 20rpx 0;background: rgba(255, 255, 255, .3);;">
			
			</view>
			
			
		<view class="list fa jcsb" @click="baocun_lan()">
			<view class="fa">
				
				<view>
					
					<text v-if="lang==0">
							更改蓝牙名称 
					</text>
					<text v-if="lang==1" >
						Change Bluetooth name
					</text>
				</view>
			</view>
			<image class="rightimg" src="../../../static/rightimg.png" mode=""></image>
		</view>
			
		<view class="list fa jcsb" style="height: 1px !important;padding:0px;margin: 0rpx 20rpx 0;background: rgba(255, 255, 255, .3);;">
		
		</view>
			
		
			
			<view class="list fa jcsb" @click="goDetail('/pagesB/mine/index/illustrate')">
				<view class="fa">
					<!-- <image class="icon" src="../../../static/share.png" mode=""></image> -->
					<view>

						<text v-if="lang==0">
								用户手册
						</text>
						<text v-if="lang==1">
							user's manual
						</text>
					</view>
				</view>
				<image class="rightimg" src="../../../static/rightimg.png" mode=""></image>
			</view>
			<view class="list fa jcsb" style="height: 1px !important;padding:0px;margin: 0rpx 20rpx 0;background: rgba(255, 255, 255, .3);;">
			
			</view>
			<view class="list fa jcsb" @click="goDetail('/pagesB/mine/index/abount')">
				<view class="fa">
				
					<view>
						<text v-if="lang==0">
								关于APP
						</text>
						<text v-if="lang==1" >
							About APP
						</text>
					</view>
				</view>
				<image class="rightimg" src="../../../static/rightimg.png" mode=""></image>
			</view>
			
		
			<view class="list fa jcsb" style="height: 1px !important;padding:0px;margin: 0rpx 20rpx 0;background: rgba(255, 255, 255, .3);;">
			
			</view>
			<view class="list fa jcsb" @click="$refs.confirmPopupRef.open()">
				<view class="fa">
					
					<view>
						<text v-if="lang==0">
								退出登录
						</text>
						<text v-if="lang==1" >
							Log out
						</text>
					</view>
				</view>
				<image class="rightimg" src="../../../static/rightimg.png" mode=""></image>
			</view>
		</view>
		
		<uni-popup ref="popup1" maskClick type="center">
			<view class="share-wrapper">
				<view class="tp">
					
					<text v-if="lang==0">
							语言切换
					</text>
					<text v-if="lang==1" style="font-size:18rpx;">
						Language switching
					</text>
				</view>
				<view class="nav_tex">
					<textarea placeholder="Enter..." :adjust-position="true" v-model="dev_name"></textarea>
				</view>
			
					
					<view class="bom">
						<view class="left">
						
							<text v-if="lang==0">
									数据来源
							</text>
							<text v-if="lang==1" >
								data sources
							</text>
						</view>
						<view class="right">
							<text v-if="is_yuancheng==0">
								
								<text v-if="lang==0">
									本地控制
								</text>
								<text v-if="lang==1" >
								Local control
								</text>
							</text>
							<text v-if="is_yuancheng==1">
								
								<text v-if="lang==0">
									远程控制
								</text>
								<text v-if="lang==1" >
									Remote control
								</text>
							
							</text>
						</view>
					</view>
					
			
					<view class="bom">
						<view class="left">
							
							<text v-if="lang==0">
									语言切换
							</text>
							<text v-if="lang==1" >
								Language switching
							</text>
						</view>
						<view class="right">
							<text v-if="is_pri==0">
							
								<text v-if="lang==0">
										是
								</text>
								<text v-if="lang==1" >
									Yes
								</text>
							</text>
							<text v-if="is_pri==1">
								
								<text v-if="lang==0">
										否
								</text>
								<text v-if="lang==1" >
									No
								</text>
								</text>
						</view>
					</view>
					
					
					<view class="bomt" @click="save_data()">
						
						<text v-if="lang==0">
								上传保存
						</text>
						<text v-if="lang==1" >
							Upload save
						</text>
					</view>
			
			
			
			</view>
		</uni-popup>
		<uni-popup ref="popup2" type="center">
			<view class="service-wrapper fa fdc">
				<view class="service-box fa fdc">
					<view class="contact">
					
						<text v-if="lang==0">
							联系微信客服
						</text>
						<text v-if="lang==1" style="font-size:23rpx;">
							Contact wechat customer service
						</text>
					</view>
					<view class="rightnow-box pr">
						<view class="rightnow">
					
							<text v-if="lang==0">
									立即联系
							</text>
							<text v-if="lang==1" style="font-size:18rpx;">
								Contact now
							</text>
						</view>
						<button type="default" open-type="contact" @click="contactService"></button>
					</view>
				</view>
				<image class="dialogclose" src="../../../static/dialogclose.png" mode="" @click="serviceClose"></image>
			</view>
		</uni-popup>
	
	
	
		<uni-popup ref="popup3" maskClick type="center">
			<view class="share-wrapper" style="height: auto;width: 700rpx;padding-bottom: 160rpx;">
				<view class="tp">
					
					<text v-if="lang==0">
						更改蓝牙名称
					</text>
					
					<text v-if="lang==1" style="font-size:18rpx;">
						Change the Bluetooth name
					</text>
				</view>
				
			<!-- 	<view style="color:#fff;width: 100%;text-align: center;">
					（只支持数字和英文字母输入）
				</view>
				 -->
				<view class="nav_tex">
				
					<input
						style="margin: 60rpx 40rpx; height: 80rpx; line-height: 80rpx; color: #fff; text-align: center; background:#3c4d70; border-radius: 8rpx;"
						:placeholder="lang?'Please enter the name of the Bluetooth you want to modify':'请输入要修改的蓝牙名称'"
						:adjust-position="true"
						maxlength="30"
						v-model="new_name"
						@input="replaceInput"
						/>
				</view>
			
					
					<view class="bomt" @click="save_name()">
						
						<text v-if="lang==0">
								确定
						</text>
						<text v-if="lang==1" >
							 save
						</text>
					</view>
			</view>
		</uni-popup>
		
		
		<uv-picker
			ref="cs_picker"
			cancelColor="#fff"
			confirmColor="#fff"
			color="#ccc"
			activeColor="#fff"
			:confirmText="lang==1?'ok':'确定'"
			:cancelText="lang==1?'cancel':'取消'"
			:columns="chesu"
			@confirm="cs_confirm"
		></uv-picker>
		
		<!-- 语言切换 picker -->
		<uv-picker
			ref="lang_picker"
			cancelColor="#fff"
			confirmColor="#fff"
			color="#ccc"
			activeColor="#fff"
			:cancelText="lang==1?'cancel':'取消'"
			:confirmText="lang==1?'ok':'确定'"
			:columns="langList"
			:defaultIndex="langDefaultIndex"
			@confirm="lang_confirm"
		></uv-picker>
		
		
		<uv-picker
			ref="btl_picker"
			cancelColor="#fff"
			confirmColor="#fff"
			color="#ccc"
			activeColor="#fff"
			:confirmText="lang==1?'ok':'确定'"
			:cancelText="lang==1?'cancel':'取消'"
			:columns="btl_arr"
			@confirm="btl_confirm"
		></uv-picker>

		<confirm-popup ref="confirmPopupRef" :content="lang ? 'Do you want to log out?' : '是否退出登录？'" :cancelText="lang ? 'Cancel' : '取消'" :confirmText="lang ? 'Confirm' : '确定'" @confirm="goDetail('/pages/login/index/index')"></confirm-popup>

		<action-sheet ref="actionSheetRef" :actions="[{ name: lang ? 'Album' : '从手机相机选择' }, { name: lang ? 'Camera' : '拍一张' }]" :cancelText="lang ? 'Cancel' : '取消'" @select="handleActionSheetSelect"></action-sheet>
		
		<tabbar :lang="lang" :current="4"></tabbar>
	</view>
</template>

<script>
	var app = getApp();
	import uniPopup from "@/components/uni-popup/uni-popup.vue";
	export default {
        components: {
			uniPopup
        }, 
		data() {
			return {
				lang:0, // 当前语言, 0=中文 1=英文
				langDefaultIndex: [0],

				new_name:"",
				login: true, //是否登录
				userType: 0, //嘉宾状态 0.未申请 1.待审核 2.通过 3.拒绝
				avatar: '', //头像
				nickname: '艾克里里', //昵称
				inviteCode: '', //邀请码
				userinfo:null,
				lan_bug:0,
				ss:[],
				dev_name:"",
				is_pri:"0",
				is_yuancheng:0,
				btl_arr:[
					["点击选择","2400","4800","9600","19200","38400","57600","115200"]
				],
				btl:0,
			};
		},
		computed: {
			// 语言列表
			langList() {
				return [
					[
						this.lang ? 'Chinese' : '中文',
						this.lang ? 'English' : '英文',
					]
				]
			},
			chesu() {
				return [
					[
						this.lang ? 'Bluetooth' : '蓝牙兼容模式',
						this.lang ? 'CAN' : 'CAN调试模式',
					]
				]
			},
		},
		onLoad() {
			uni.hideTabBar();
			
			// this.getInvite();
			
			// share() {
			// 	this.$refs.popup1.open();
			// },
			// // 分享好友
			// shareFriend() {
			// 	this.$refs.popup1.close();
			// },
			// this.baocun_lan()
			
		},
		onShow() {
		
			if(uni.getStorageSync('lang')){
				this.lang = uni.getStorageSync('lang')
				this.langDefaultIndex= [this.lang]
			}
			
			
			
			var ss = uni.getStorageSync('dev_data');
			console.log("mv22",ss.softstart_level_index)
			
			this.ss = ss;
			
			if(uni.getStorageSync('token')){
				this.get_user_info()
			}
			
			
			let lan_bug = uni.getStorageSync('lan_bug')
			if(lan_bug){
				this.lan_bug = uni.getStorageSync('lan_bug')
			}
			
			// if (app.globalData.connected == true) {
			// 	this.getbtl();
			// }
			
		},
		methods: {
			goport(){
			
				uni.switchTab({
					url:"/pages/release/index/index"
				})
				
			},
			duankai(type){
				let that = this;
				that.deviceInfo =  uni.getStorageSync('deviceInfo');
				uni.setStorageSync('dev_data', null);
				uni.setStorageSync('deviceList', null);
				uni.setStorageSync('serviceInfo',null);
				uni.setStorageSync('writeCharacteristicsInfo', null);
				uni.setStorageSync('notifyCharacteristicsInfo', null);
				uni.setStorageSync('deviceInfo', null);
					
				uni.closeBluetoothAdapter({
				  success(res) {
					   uni.closeBLEConnection({
						 deviceId:that.deviceInfo.deviceId,
						 success(res) {
								//重新练
								console.log(111,res)
								that.tixing(type);
								
						
						 }, fail(error) {
							 	console.log(2222,error)
								//重新练
								that.tixing(type);
						}
					   })
				  },
				  fail(error) {
						console.log(3333,error)
						that.tixing(type);
				   
				  }
				})
			},
			tixing(type){
				
			
				uni.hideLoading();
				app.globalData.connected = false;
				if(type == 1){
					if(this.lang==0){
						
						uni.showModal({
						    title: '模块名字已经修改成功，请重新连接模块',
						    content: '数据读取成功',
							showCancel: false,//没有取消按钮的弹框
						    success: function (res) {
								
								uni.redirectTo({
									url: '/pages/home/index/lanya'
								});
						    }
						});
					}else{
						uni.showModal({
						    title: 'prompt',
						    content: 'The module name has been successfully modified. Please reconnect the module',
							// cancelText: "cancel", // 取消按钮的文字  
							confirmText: "ok", // 确认按钮的文字  
							showCancel:false,
						    success: function (res) {
								
								uni.redirectTo({
								 url: '/pages/home/index/lanya'
								});
						    }
						});
						
					}
				}else{
					if(this.lang==0){
					
						uni.showModal({
						    title: '模块波特率已经修改成功，请重新连接模块',
						    content: '数据读取成功',
							showCancel: false,//没有取消按钮的弹框
						    success: function (res) {
							
								uni.redirectTo({
								 url: '/pages/home/index/lanya'
								});
						    }
						});
					}else{
						uni.showModal({
						    title: 'prompt',
						    content: 'The module baud rate has been modified to, please reconnect the module',
							// cancelText: "cancel", // 取消按钮的文字  
							confirmText: "ok", // 确认按钮的文字  
							showCancel:false,
						    success: function (res) {
									
									uni.redirectTo({
										url: '/pages/home/index/lanya'
									});
						    }
						});
					}
				}
				
			},
			getbtl(){
				
				// ["点击选择","AUTO","125K","250K","500K","1M"]
				if (app.globalData.connected != true) {
					if(this.lang==0){
						uni.showToast({
							title: '需要先连接蓝牙',
							icon:"none"
						})
					}else{
						uni.showToast({
							title: 'Bluetooth needs to be connected first',
							icon:"none"
						})
					}
					return;
				}
				
					
					 if(this.lang==0){
					 
						uni.showLoading({
							 title: '加载中....',
							mask:true
						});
					 }else{
						uni.showLoading({
							 title: 'looding....',
							mask:true
						});
					 }
					 
					 let that  = this;
					 //发送？
					 app.globalData.looksa = 0;
					 uni.onBLECharacteristicValueChange((res) => {
					 	const value = Array.prototype.map.call(new Uint8Array(res.value), (bit) => bit)
					 	var str = "";	
					 	for (var i = 0; i < value.length; i++) {
					 	  str += String.fromCharCode(value[i]);
					 	}
					
						
						if(app.globalData.looksa == 2){
							uni.hideLoading();
							app.globalData.looksa = 0;
							app.globalData.get_btl_g = 0;
							//设置成功
							console.log("home ---结果输出11111",str,str.substr(-3,1));
							that.btl = str.substr(-3,1);
							console.log("home ---结果输出",that.btl);
							
						}else{
							console.log("home ---获取波特率率监听到的值",value,str);
						}
					 	
					 })
					 
					 	
				app.globalData.looksa = 1;
				
				
				var ss = uni.getStorageSync('dev_data');
				
				this.ss.deviceList = uni.getStorageSync('deviceList');
				this.ss.serviceInfo = uni.getStorageSync('serviceInfo');
				this.ss.writeCharacteristicsInfo = uni.getStorageSync('writeCharacteristicsInfo');
				
				
				this.ss.notifyCharacteristicsInfo = uni.getStorageSync('notifyCharacteristicsInfo');
				this.ss.deviceInfo = uni.getStorageSync('deviceInfo');
				
				
				this.ss.deviceId= this.ss.deviceInfo.deviceId;//decodeURIComponent(options.deviceId);
				this.ss.serviceId= this.ss.serviceInfo.uuid;//decodeURIComponent(options.name);
				
				console.log(this.ss.deviceId,this.ss.serviceId,this.ss.writeCharacteristicsInfo.uuid,77777777)
				
				
				if (app.globalData.connected == true) {
					
					app.globalData.get_btl_g = 0;
					setTimeout(function(){
						if(app.globalData.get_btl_g == 1){
							uni.hideLoading();
							if(that.lang==0){
								uni.showToast({
								  title: '获取超时',
								  icon: 'none',
								  mask: true,
								})
							}else{
									uni.showToast({
									  title: 'getData timeout',
									  icon: 'none',
									  mask: true,
									})
							}
							return;
						}
						
					},5000)
					app.globalData.get_btl_g = 1;
					
					
					
				  let strArray = new Uint8Array([0x41, 0x54, 0x2B, 0x41, 0x50, 0x50, 0x41,0x54, 0x30, 0x0D,0x0A]);
				
				  uni.writeBLECharacteristicValue({
				    // 这里的 deviceId 需要在 getBluetoothDevices 或 onBluetoothDeviceFound 接口中获取
				    deviceId: that.ss.deviceId,
				    // 这里的 serviceId 需要在 getBLEDeviceServices 接口中获取
				    serviceId: that.ss.serviceId,
				    // 这里的 characteristicId 需要在 getBLEDeviceCharacteristics 接口中获取
				    characteristicId: that.ss.writeCharacteristicsInfo.uuid,
				    // 这里的value是ArrayBuffer类型
				    value: strArray.buffer,
				    writeType: 'writeNoResponse',
				    success(res) {
						
						console.log("退出AT成功",979797979);
						
						setTimeout(function(){
							let strArray = new Uint8Array([0x41, 0x54, 0x2B, 0x41, 0x50, 0x50, 0x41,0x54, 0x0D, 0x0A]);
									
									  uni.writeBLECharacteristicValue({
										// 这里的 deviceId 需要在 getBluetoothDevices 或 onBluetoothDeviceFound 接口中获取
										deviceId: that.ss.deviceId,
										// 这里的 serviceId 需要在 getBLEDeviceServices 接口中获取
										serviceId: that.ss.serviceId,
										// 这里的 characteristicId 需要在 getBLEDeviceCharacteristics 接口中获取
										characteristicId: that.ss.writeCharacteristicsInfo.uuid,
										// 这里的value是ArrayBuffer类型
										value: strArray.buffer,
										writeType: 'writeNoResponse',
										success(res) {
											
											
											console.log("进入AT成功",979797979);
											
											let faasong = [];
												//发送波特特利率  index  41 54 2b 42 41 55 44 0D 0A
												
												let str = that.new_name
												let ascii = [0x41, 0x54, 0x2B, 0x42, 0x41,0x55, 0x44,0x0D,0x0A];  

												//发送  AT+NAME模块名字  {41 54 2B 4E 41 4D 45 模块名字 0D 0A}
												setTimeout(function(){
													let strArray = new Uint8Array(ascii);
																console.log('new name---',ascii,99999);
															 //  let temp = strArray[0];
															 //  for (let i = 1; i < strArray.length - 2; i++) {
																// temp ^= strArray[i];
															 //  }
															 //  strArray[strArray.length - 2] = temp;
															  // that.writeBLECharacteristicValue(strArray.buffer);
															  uni.writeBLECharacteristicValue({
																// 这里的 deviceId 需要在 getBluetoothDevices 或 onBluetoothDeviceFound 接口中获取
																deviceId: that.ss.deviceId,
																// 这里的 serviceId 需要在 getBLEDeviceServices 接口中获取
																serviceId: that.ss.serviceId,
																// 这里的 characteristicId 需要在 getBLEDeviceCharacteristics 接口中获取
																characteristicId: that.ss.writeCharacteristicsInfo.uuid,
																// 这里的value是ArrayBuffer类型
																value: strArray.buffer,
																writeType: 'writeNoResponse',
																success(res) {
																	
																		app.globalData.looksa = 2;
																	
																		console.log("发送获取代码成功",979797979);
																			
																			let strArray = new Uint8Array([0x41, 0x54, 0x2B, 0x41, 0x50, 0x50, 0x41,0x54, 0x30, 0x0D,0x0A]);
																			setTimeout(function(){
																				// let strArray = new Uint8Array(strArray);
																							console.log('new tuichuAt',[0x41, 0x54, 0x2B, 0x41, 0x50, 0x50, 0x41,0x54, 0x30, 0x0D,0x0A],99999);
																						 //  let temp = strArray[0];
																						 //  for (let i = 1; i < strArray.length - 2; i++) {
																							// temp ^= strArray[i];
																						 //  }
																						 //  strArray[strArray.length - 2] = temp;
																						  // that.writeBLECharacteristicValue(strArray.buffer);
																						  uni.writeBLECharacteristicValue({
																							// 这里的 deviceId 需要在 getBluetoothDevices 或 onBluetoothDeviceFound 接口中获取
																							deviceId: that.ss.deviceId,
																							// 这里的 serviceId 需要在 getBLEDeviceServices 接口中获取
																							serviceId: that.ss.serviceId,
																							// 这里的 characteristicId 需要在 getBLEDeviceCharacteristics 接口中获取
																							characteristicId: that.ss.writeCharacteristicsInfo.uuid,
																							// 这里的value是ArrayBuffer类型
																							value: strArray.buffer,
																							writeType: 'writeNoResponse',
																							success(res) {
																								
																								console.log("发送退出AT退出",979797979);
																							},
																							fail(error) {
																							   console.log("发送获取代码失败"+error)
																							},
																						})
																			},300)	
															
															
															
															
																},
																fail(error) {
																   console.log("发送获取代码失败"+error)
																},
															})
												},300)	 
										},
										fail(error) {
										  console.log("进入AT失败"+error)
										},
									})
						},300)
								 
				    },
				    fail(error) {
				      // console.log(')
				      console.log("退出AT失败"+error)
				    },
				  })
				}
				
				
			},
			duqu(){
				
			},
			baocun_lan(){
					this.$refs.popup3.open();
			},
			replaceInput(event){
			 
				var that = this;
				setTimeout(() => {
					that.new_name = event.target.value.replace(/[^0-9a-zA-Z]/g, '')
				}, 10)
			},
			save_name(e){
				
				
				
				
				if(this.new_name.length <1){
					if(this.lang==0){
						uni.showToast({
							title: '需要输入新的的名称',
							icon:"none"
						})
						
					}else{
						uni.showToast({
							title: 'needs to new dev_name',
							icon:"none"
						})
					}
					return;
				}
				
				
				uni.onBLECharacteristicValueChange((res) => {
					const value = Array.prototype.map.call(new Uint8Array(res.value), (bit) => bit)
					var str = "";	
					for (var i = 0; i < value.length; i++) {
					  str += String.fromCharCode(value[i]);
					}
					app.globalData.save_name_g = 2;
					console.log("name----bit率监听到的值",value,str);
					
				})
				
				
				let str = this.new_name
				// let ascii = [];  
				  
				// for (let i = 0; i < str.length; i++) {  
				//   ascii.push(str.charCodeAt(i));  
				// }  
				
				function asciiToHex(str) {  
				    return str.split('').map(function(char) {  
				        var hex = char.charCodeAt(0).toString(16);  
				        return hex.length < 2 ? "0x"+'0' + hex : "0x"+hex;  
				    }).join(' ');  
				}
				let ascii = asciiToHex(str);
	
				
				
				
				
				// ["点击选择","AUTO","125K","250K","500K","1M"]
				if (app.globalData.connected != true) {
					if(this.lang==0){
						uni.showToast({
							title: '需要先连接蓝牙',
							icon:"none"
						})
					}else{
						uni.showToast({
							title: 'Bluetooth needs to be connected first',
							icon:"none"
						})
					}
					return;
				}
				
					
				
					 
				var that = this;
				var ss = uni.getStorageSync('dev_data');
				
				this.ss.deviceList = uni.getStorageSync('deviceList');
				this.ss.serviceInfo = uni.getStorageSync('serviceInfo');
				this.ss.writeCharacteristicsInfo = uni.getStorageSync('writeCharacteristicsInfo');
				
				
				this.ss.notifyCharacteristicsInfo = uni.getStorageSync('notifyCharacteristicsInfo');
				this.ss.deviceInfo = uni.getStorageSync('deviceInfo');
				
				
				this.ss.deviceId= this.ss.deviceInfo.deviceId;//decodeURIComponent(options.deviceId);
				this.ss.serviceId= this.ss.serviceInfo.uuid;//decodeURIComponent(options.name);
				
				console.log(this.ss.deviceId,this.ss.serviceId,this.ss.writeCharacteristicsInfo.uuid,77777777)
				
				//开始修改并触发超时的处理
			
				
				if (app.globalData.connected == true) {
					
					if(this.lang==0){
						uni.showLoading({
							 title: '设置中....',
							mask:true
						});
					 }else{
						 uni.showLoading({
						 	 title: 'setting....',
						 	mask:true
						 });
					 }
					
					
					
					app.globalData.save_name_g = 0;
					setTimeout(function(){
						if(app.globalData.save_name_g == 1){
							uni.hideLoading();
							if(that.lang==0){
								uni.showToast({
								  title: '设置超时',
								  icon: 'none',
								  mask: true,
								})
							}else{
									uni.showToast({
									  title: 'setting timeout',
									  icon: 'none',
									  mask: true,
									})
							}
							return;
						}
					},5000)
					app.globalData.save_name_g = 1;
					
					
				  let strArray = new Uint8Array([0x41, 0x54, 0x2B, 0x41, 0x50, 0x50, 0x41,0x54, 0x30, 0x0D,0x0A]);
				  //console.log(strArray);
				  // let temp = strArray[0];
				  // for (let i = 1; i < strArray.length - 2; i++) {
				  //   temp ^= strArray[i];
				  // }
				  // strArray[strArray.length - 2] = temp;
				  
				  
				  // that.writeBLECharacteristicValue(strArray.buffer);
				  uni.writeBLECharacteristicValue({
				    // 这里的 deviceId 需要在 getBluetoothDevices 或 onBluetoothDeviceFound 接口中获取
				    deviceId: that.ss.deviceId,
				    // 这里的 serviceId 需要在 getBLEDeviceServices 接口中获取
				    serviceId: that.ss.serviceId,
				    // 这里的 characteristicId 需要在 getBLEDeviceCharacteristics 接口中获取
				    characteristicId: that.ss.writeCharacteristicsInfo.uuid,
				    // 这里的value是ArrayBuffer类型
				    value: strArray.buffer,
				    writeType: 'writeNoResponse',
				    success(res) {
						
						console.log("退出AT成功",979797979);
						
						setTimeout(function(){
							let strArray = new Uint8Array([0x41, 0x54, 0x2B, 0x41, 0x50, 0x50, 0x41,0x54, 0x0D, 0x0A]);
									  //console.log(strArray);
									 //  let temp = strArray[0];
									 //  for (let i = 1; i < strArray.length - 2; i++) {
										// temp ^= strArray[i];
									 //  }
									 //  strArray[strArray.length - 2] = temp;
									  // that.writeBLECharacteristicValue(strArray.buffer);
									  uni.writeBLECharacteristicValue({
										// 这里的 deviceId 需要在 getBluetoothDevices 或 onBluetoothDeviceFound 接口中获取
										deviceId: that.ss.deviceId,
										// 这里的 serviceId 需要在 getBLEDeviceServices 接口中获取
										serviceId: that.ss.serviceId,
										// 这里的 characteristicId 需要在 getBLEDeviceCharacteristics 接口中获取
										characteristicId: that.ss.writeCharacteristicsInfo.uuid,
										// 这里的value是ArrayBuffer类型
										value: strArray.buffer,
										writeType: 'writeNoResponse',
										success(res) {
											
											
											let faasong = [];
												//发送波特特利率  index
												
												let str = that.new_name
												let ascii = [0x41, 0x54, 0x2B, 0x4E, 0x41,0x4D, 0x45];  
												  
												for (let i = 0; i < str.length; i++) {  
												  ascii.push(str.charCodeAt(i));  
												}  
												 ascii.push(0x0D);  
												 ascii.push(0x0A);  
												 
												//发送  AT+NAME模块名字  {41 54 2B 4E 41 4D 45 模块名字 0D 0A}
												setTimeout(function(){
													let strArray = new Uint8Array(ascii);
																console.log('new name---',ascii,99999);
															 //  let temp = strArray[0];
															 //  for (let i = 1; i < strArray.length - 2; i++) {
																// temp ^= strArray[i];
															 //  }
															 //  strArray[strArray.length - 2] = temp;
															  // that.writeBLECharacteristicValue(strArray.buffer);
															  uni.writeBLECharacteristicValue({
																// 这里的 deviceId 需要在 getBluetoothDevices 或 onBluetoothDeviceFound 接口中获取
																deviceId: that.ss.deviceId,
																// 这里的 serviceId 需要在 getBLEDeviceServices 接口中获取
																serviceId: that.ss.serviceId,
																// 这里的 characteristicId 需要在 getBLEDeviceCharacteristics 接口中获取
																characteristicId: that.ss.writeCharacteristicsInfo.uuid,
																// 这里的value是ArrayBuffer类型
																value: strArray.buffer,
																writeType: 'writeNoResponse',
																success(res) {
															
																		//发送波特特利率  index
																		
																							// let faasong = [];
																								//发送波特特利率  index
																							
																													  
																				setTimeout(function(){			   
																					let strArray = new Uint8Array([0x41, 0x54, 0x2B, 0x52, 0x45,0x53, 0x45,0x54, 0x0D, 0x0A]);
																							  //console.log(strArray);
																							 //  let temp = strArray[0];
																							 //  for (let i = 1; i < strArray.length - 2; i++) {
																								// temp ^= strArray[i];
																							 //  }
																							 //  strArray[strArray.length - 2] = temp;
																							  // that.writeBLECharacteristicValue(strArray.buffer);
																							  uni.writeBLECharacteristicValue({
																								// 这里的 deviceId 需要在 getBluetoothDevices 或 onBluetoothDeviceFound 接口中获取
																								deviceId: that.ss.deviceId,
																								// 这里的 serviceId 需要在 getBLEDeviceServices 接口中获取
																								serviceId: that.ss.serviceId,
																								// 这里的 characteristicId 需要在 getBLEDeviceCharacteristics 接口中获取
																								characteristicId: that.ss.writeCharacteristicsInfo.uuid,
																								// 这里的value是ArrayBuffer类型
																								value: strArray.buffer,
																								writeType: 'writeNoResponse',
																								success(res) {
																									
																										//发送波特特利率  index
																										//断并重新练连蓝牙？
																										let  deviceList = uni.getStorageSync('deviceList');
																										deviceList.name = str
																										uni.setStorageSync('deviceList',deviceList);
																										
																										setTimeout(function(){
																											if(app.globalData.save_name_g  == 2){
																												app.globalData.save_name_g = 0;
																												that.duankai(1);
																											}
																											
																											
																										},300)
																											 
																								},
																								fail(error) {
																								  console.log("发送重启失败"+error)
																								},
																							})
																				},500)	 
																					
																			 
																},
																fail(error) {
																   console.log("发送设置代码失败"+error)
																},
															})
												},500)	 
										},
										fail(error) {
										  console.log("进入AT失败"+error)
										},
									})
						},500)
								 
				    },
				    fail(error) {
				      // console.log(')
				      console.log("退出AT失败"+error)
				    },
				  })
				}
				
			},
			btl_confirm(e){
			
				
				var index = e.indexs[0];
				if(index == 0){
					return
				}
				
				// ["点击选择","AUTO","125K","250K","500K","1M"]
				if (app.globalData.connected != true) {
					if(this.lang==0){
						uni.showToast({
							title: '需要先连接蓝牙',
							icon:"none"
						})
					}else{
						uni.showToast({
							title: 'Bluetooth needs to be connected first',
							icon:"none"
						})
					}
					return;
				}
				
				
					uni.onBLECharacteristicValueChange((res) => {
						const value = Array.prototype.map.call(new Uint8Array(res.value), (bit) => bit)
						var str = "";	
						for (var i = 0; i < value.length; i++) {
						  str += String.fromCharCode(value[i]);
						}
						app.globalData.save_btl_g = 2;
						console.log("bit率监听到的值",value,str);
					})
		
					
				var that = this;
				var ss = uni.getStorageSync('dev_data');
				this.ss.deviceList = uni.getStorageSync('deviceList');
				this.ss.serviceInfo = uni.getStorageSync('serviceInfo');
				this.ss.writeCharacteristicsInfo = uni.getStorageSync('writeCharacteristicsInfo');
				
				this.ss.notifyCharacteristicsInfo = uni.getStorageSync('notifyCharacteristicsInfo');
				this.ss.deviceInfo = uni.getStorageSync('deviceInfo');
				this.ss.deviceId= this.ss.deviceInfo.deviceId;//decodeURIComponent(options.deviceId);
				this.ss.serviceId= this.ss.serviceInfo.uuid;//decodeURIComponent(options.name);
				
				console.log(this.ss.deviceId,this.ss.serviceId,this.ss.writeCharacteristicsInfo.uuid,77777777)
				
				if (app.globalData.connected == true) {
					
					if(this.lang==0){
						uni.showLoading({
							 title: '设置中....',
							mask:true
						});
					 }else{
						 uni.showLoading({
						 	 title: 'setting....',
						 	mask:true
						 });
					 }
					
					app.globalData.save_btl_g = 0;
					setTimeout(function(){
						if(app.globalData.save_btl_g == 1){
							uni.hideLoading();
							if(that.lang==0){
								uni.showToast({
								  title: '设置超时',
								  icon: 'none',
								  mask: true,
								})
							}else{
									uni.showToast({
									  title: 'setting timeout',
									  icon: 'none',
									  mask: true,
									})
							}
							return;
						}
					},5000)
					app.globalData.save_btl_g = 1;
					
								
				  let strArray = new Uint8Array([0x41, 0x54, 0x2B, 0x41, 0x50, 0x50, 0x41,0x54, 0x30, 0x0D,0x0A]);
				  
				  //console.log(strArray);
				  // let temp = strArray[0];
				  // for (let i = 1; i < strArray.length - 2; i++) {
				  //   temp ^= strArray[i];
				  // }
				  // strArray[strArray.length - 2] = temp;
				  
				  
				  
				  // that.writeBLECharacteristicValue(strArray.buffer)0x41, 0x54, 0x2B, 0x41, 0x50, 0x50, 0x41,0x54, 0x30, 0x0D,0x0A;
				  uni.writeBLECharacteristicValue({
				    // 这里的 deviceId 需要在 getBluetoothDevices 或 onBluetoothDeviceFound 接口中获取
				    deviceId: that.ss.deviceId,
				    // 这里的 serviceId 需要在 getBLEDeviceServices 接口中获取
				    serviceId: that.ss.serviceId,
				    // 这里的 characteristicId 需要在 getBLEDeviceCharacteristics 接口中获取
				    characteristicId: that.ss.writeCharacteristicsInfo.uuid,
				    // 这里的value是ArrayBuffer类型
				    value: strArray.buffer,
				    writeType: 'writeNoResponse',
				    success(res) {
					
						//	//  {41 54 2B 41 50 50 41 54 0D 0A}
						setTimeout(function(){
							let strArray = new Uint8Array([0x41, 0x54, 0x2B, 0x41, 0x50, 0x50, 0x41,0x54,0x0D, 0x0A]);
									  //console.log(strArray);
									 //  let temp = strArray[0];
									 //  for (let i = 1; i < strArray.length - 2; i++) {
										// temp ^= strArray[i];
									 //  }
									 //  strArray[strArray.length - 2] = temp;
									  
									  
									  // that.writeBLECharacteristicValue(strArray.buffer);
									  uni.writeBLECharacteristicValue({
										// 这里的 deviceId 需要在 getBluetoothDevices 或 onBluetoothDeviceFound 接口中获取
										deviceId: that.ss.deviceId,
										// 这里的 serviceId 需要在 getBLEDeviceServices 接口中获取
										serviceId: that.ss.serviceId,
										// 这里的 characteristicId 需要在 getBLEDeviceCharacteristics 接口中获取
										characteristicId: that.ss.writeCharacteristicsInfo.uuid,
										// 这里的value是ArrayBuffer类型
										value: strArray.buffer,
										writeType: 'writeNoResponse',
										success(res) {
											
											
											let faasong = [];
												//发送波特特利率  index
												switch(index){
													case 1:
														 faasong = [0x41, 0x54, 0x2B, 0x42,0x41,0x55,0x44,0x31, 0x0D, 0x0A]
													break;
													case 2:
														 faasong = [0x41, 0x54, 0x2B, 0x42,0x41,0x55,0x44,0x32, 0x0D, 0x0A]
													break;
													case  3:
														 faasong = [0x41, 0x54, 0x2B, 0x42,0x41,0x55,0x44,0x33, 0x0D, 0x0A]
													break;
													case 4:
													 faasong = [0x41, 0x54, 0x2B, 0x42,0x41,0x55,0x44,0x34, 0x0D, 0x0A]
													break;
													case 5:
														 faasong = [0x41, 0x54, 0x2B, 0x42,0x41,0x55,0x44,0x35, 0x0D, 0x0A]
													break;
													case 6:
														 faasong = [0x41, 0x54, 0x2B, 0x42,0x41,0x55,0x44,0x36, 0x0D, 0x0A]
													break;
													case 7:
												
													   faasong = [0x41, 0x54, 0x2B, 0x42,0x41,0x55,0x44,0x37, 0x0D, 0x0A]
													break;
												}
												setTimeout(function(){
													let strArray = new Uint8Array(faasong);
															  //console.log(strArray);
															  
															 //  let temp = strArray[0];
															 //  for (let i = 1; i < strArray.length - 2; i++) {
																// temp ^= strArray[i];
															 //  }
															 //  strArray[strArray.length - 2] = temp;
															 
															 
															  // that.writeBLECharacteristicValue(strArray.buffer);
															  uni.writeBLECharacteristicValue({
																// 这里的 deviceId 需要在 getBluetoothDevices 或 onBluetoothDeviceFound 接口中获取
																deviceId: that.ss.deviceId,
																// 这里的 serviceId 需要在 getBLEDeviceServices 接口中获取
																serviceId: that.ss.serviceId,
																// 这里的 characteristicId 需要在 getBLEDeviceCharacteristics 接口中获取
																characteristicId: that.ss.writeCharacteristicsInfo.uuid,
																// 这里的value是ArrayBuffer类型
																value: strArray.buffer,
																writeType: 'writeNoResponse',
																success(res) {
																	
																	
																		//发送波特特利率  index  {41 54 2B 52 45 53 45 54 0D 0A}
																		setTimeout(function(){
																			let strArray = new Uint8Array([0x41, 0x54, 0x2B, 0x52, 0x45,0x53, 0x45,0x54, 0x0D, 0x0A]);
																					  //console.log(strArray);
																					 //  let temp = strArray[0];
																					 //  for (let i = 1; i < strArray.length - 2; i++) {
																						// temp ^= strArray[i];
																					 //  }
																					 //  strArray[strArray.length - 2] = temp;
																					  
																					  // that.writeBLECharacteristicValue(strArray.buffer);
																					  uni.writeBLECharacteristicValue({
																						// 这里的 deviceId 需要在 getBluetoothDevices 或 onBluetoothDeviceFound 接口中获取
																						deviceId: that.ss.deviceId,
																						// 这里的 serviceId 需要在 getBLEDeviceServices 接口中获取
																						serviceId: that.ss.serviceId,
																						// 这里的 characteristicId 需要在 getBLEDeviceCharacteristics 接口中获取
																						characteristicId: that.ss.writeCharacteristicsInfo.uuid,
																						// 这里的value是ArrayBuffer类型
																						value: strArray.buffer,
																						writeType: 'writeNoResponse',
																						success(res) {
																						
																							setTimeout(function(){
																								if(app.globalData.save_btl_g ==2){
																									app.globalData.save_btl_g = 0;
																									that.duankai(0);
																								}
																								
																								// if(that.lang==0){
																								// 	uni.showToast({
																								// 	  title: '设置成功',
																								// 	  icon: 'none',
																								// 	  mask: true,
																								// 	})
																								// }else{
																								// 		uni.showToast({
																								// 		  title: 'setting is ok',
																								// 		  icon: 'none',
																								// 		  mask: true,
																								// 		})
																								// }
																							},300)
																							// let faasong = [];
																								//发送波特特利率  index
																								
																						},
																						fail(error) {
																						  console.log('faailll444444444')
																						  console.log(error)
																						},
																					})
																		},500)
																			 
																},
																fail(error) {
																   
																},
															})
												},500)	 
										},
										fail(error) {
										  
										},
									})
						},500)
								 
				    },
				    fail(error) {
				   
				    },
				  })
				}
				
			},
			btl_openPicker(){
				this.$refs.btl_picker.open();
			},
			save_avatar() {
			
				uni.showToast({title: '加载中...',icon:'loading',mask:true})
				var _this = this;
				
				console.log(_this.userinfo.avatar,77777777777)
				
			},
			handleActionSheetSelect(event) {
				if(!uni.getStorageSync('token')){
					return;
				}
				console.log(event)
				
				let _this = this;
				if (event.index == 0) {
					uni.chooseImage({
						count: 1,
						sizeType: ['compressed'],
						sourceType: ['album'],
						success: function(res) {
							console.log(9797971,res.tempFilePaths[0])
							
							_this.$api.uploadFile(res.tempFilePaths[0], _this.$store
								.state.token,
								function(res2) {
									
									if (res2.code == 1) {
										console.log(res2.data.fullurl,8881)
										uni.showToast({title: 'lodding...',icon:'loading',mask:true})
										_this.$api.request('/api/user/profile', {avatar:res2.data.fullurl}, _this.$store.state.token, function(res){
											uni.hideLoading();
											_this.get_user_info();
											uni.showToast({
												title: res.msg,
													mask:true,
													icon:'none',
												})
											
										});
							
									}
								});
						}
					});
				} else if (event.index == 1) {
					uni.chooseImage({
						count: 1,
						sizeType: ['original', 'compressed'],
						sourceType: ['camera'],
						success: function(res) {
							console.log(9797972,res.tempFilePaths[0])
							_this.$api.uploadFile(res.tempFilePaths[0], _this.$store
								.state.token,
								function(res2) {
									console.log(res2,8882)
									if (res2.code == 1) {
									
										uni.showToast({title: 'lodding...',icon:'loading',mask:true})
										_this.$api.request('/api/user/profile', {avatar:res2.data.fullurl}, _this.$store.state.token, function(res){
											uni.hideLoading();
											_this.get_user_info();
											uni.showToast({
												title: res.msg,
													mask:true,
													icon:'none',
												})
											
										});
									
									}
								});
						}
					});
				}
			},
			gologin(){
				uni.navigateTo({
					url: "/pages/login/index/index"
				})
				
				// uni.switchTab({
				// 	url:  "/pages/login/index/index"
				// })
			},
			jiebang(){
				let _this = this;
				let that = this;
				if(!this.userinfo.dev_id){
					if(that.lang == 1){	
						uni.showToast({
							title:'没有可解绑设备',
							icon:"none"
						})
					}else{
						uni.showToast({
							title:'没有可解绑设备',
							icon:"none"
						})
					}
					return 
				}
				
				
			
				if(that.lang == 1){
					
					uni.showModal({
						title: 'Are you sure to unbind',
						// content: '您的位置信息将用获取信息',
						success: (res) => {
							if (res.confirm) {
								that.$api.request('/api/user/jiebang', {}, '', function(res){
									console.log(res);
									that.get_user_info();
									uni.showModal({
											title: 'Operation successful ',
											cancelText: "cancel", // 取消按钮的文字
											confirmText: "ok", // 确认按钮的文字  
											// content: '您的位置信息将用获取信息',
											success: (res) => {
											}
										})
								
								});							
							}
						
						}
					})
				}else{
					uni.showModal({
						title: '是否确认解除绑定 ',
						// content: '您的位置信息将用获取信息',
						success: (res) => {
							if (res.confirm) {
								that.$api.request('/api/user/jiebang', {}, '', function(res){
									console.log(res);
										
											that.get_user_info();
																		
											uni.showModal({
													title: '操作成功 ',
													// content: '您的位置信息将用获取信息',
													success: (res) => {
													}
											})
								});
							}
						}
					})
				}
			
			},
			daoru(){
				let that = this;
				let inifile_path;
				//wx.navigateTo({url: '/pages/showing/showing'})
				wx.chooseMessageFile({
				  count: 1,
				  type: 'file',
				  extension: ['ini'],
				  success(res) {
					inifile_path = res.tempFiles;
					console.log('chooseMessageFile', inifile_path)
			
					const fs = wx.getFileSystemManager()
					try {
					  let file_res = fs.readFileSync(inifile_path[0].path, 'binary', 0)
					  that.import_pararm_config(file_res);
					} catch (e) {
					  console.error(e)
					}
					// that.data.param_read_success_flag = true;
					// that.save_confg();
				  }
				})
				console.log("导入配置")
			},
		   setData:function(obj){
			
			console.log(22)
			let that = this;    
			let keys = [];    
			let val,data;    
			
				obj.forEach(function(element, index) {
				  console.log("索引：" + index);
				});

			},
			get_page0_information: function () {
			    let that = this;
			    let temp;
			    let tab = [0x05, 0x0a, 0x14, 0x1e, 0x28, 0, 0, 0, 0, 0, 0, 0, 0, 0];
			    that.data.page0_tx_message[5] = tab[that.data.pm_type_index];
			    that.data.page0_tx_message[6] = that.data.voltage_level_index;
			    that.data.page0_tx_message[6] |= (that.data.manufacturer_code_index << 4) & 0xff;
			    temp = (that.data.over_voltage_value * 10);
			    that.data.page0_tx_message[7] = (temp >> 8) & 0xff;
			    that.data.page0_tx_message[8] = (temp) & 0xff;
			    temp = (that.data.under_voltage_value * 10);
			    that.data.page0_tx_message[16] = (temp >> 8) & 0xff;
			    that.data.page0_tx_message[17] = (temp) & 0xff;
			
			    temp = (that.data.soft_under_voltage_value * 10);
			    that.data.page0_tx_message[9] = (temp >> 8) & 0xff;
			    that.data.page0_tx_message[10] = (temp) & 0xff;
			
			    temp = (that.data.under_voltage_threshold_value * 10);
			    that.data.page0_tx_message[11] = (temp) & 0xff;
			
			    temp = that.data.bus_current_limit_value;
			    that.data.page0_tx_message[12] = (temp >> 8) & 0xff;
			    that.data.page0_tx_message[13] = (temp) & 0xff;
			
			    temp = that.data.phase_current_value;
			    that.data.page0_tx_message[14] = (temp >> 8) & 0xff;
			    that.data.page0_tx_message[15] = (temp) & 0xff;
			
			    temp = that.data.vol_calibration_value;
			    that.data.page0_tx_message[18] = (temp >> 8) & 0xff;
			    that.data.page0_tx_message[19] = (temp) & 0xff;
			
			    temp = that.data.cur_calibration_value;
			    that.data.page0_tx_message[20] = (temp >> 8) & 0xff;
			    that.data.page0_tx_message[21] = (temp) & 0xff;
			  },
			  get_page1_information: function () {
			    let that = this;
			    let temp;
			    temp = that.data.sport_bus_current_limit;
			    that.data.page1_tx_message[5] = (temp >> 8) & 0xff;
			    that.data.page1_tx_message[6] = (temp) & 0xff;
			
			    temp = that.data.low_speed_percent;
			    that.data.page1_tx_message[7] = (temp) & 0xff;
			
			    temp = that.data.mid_speed_percent;
			    that.data.page1_tx_message[8] = (temp) & 0xff;
			
			    temp = that.data.high_speed_percent;
			    that.data.page1_tx_message[9] = (temp) & 0xff;
			
			    temp = that.data.flux_weak_value;
			    that.data.page1_tx_message[10] = (temp >> 8) & 0xff;
			    that.data.page1_tx_message[11] = (temp) & 0xff;
			
			    temp = that.data.phase_Kp;
			    that.data.page1_tx_message[12] = (temp >> 8) & 0xff;
			    that.data.page1_tx_message[13] = (temp) & 0xff;
			
			    temp = that.data.phase_current_limit_value;
			    that.data.page1_tx_message[14] = (temp >> 8) & 0xff;
			    that.data.page1_tx_message[15] = (temp) & 0xff;
			
			    temp = that.data.turtle_speed_pecent;
			    that.data.page1_tx_message[17] = temp & 0xff;
			
			    that.data.page1_tx_message[16] = 0;
			    if (that.data.motor_type_selcet_value == 2) {
			      that.data.page1_tx_message[16] |= 0x10;
			    }
			    if (that.data.soft_start_flag == true) {
			      that.data.page1_tx_message[16] |= 0x80;
			    }
			    if (that.data.motor_noise_forbid_falg == true) {
			      that.data.page1_tx_message[16] |= 0x40;
			    }
			    if (that.data.dot_switch_selcet_flag == 2) {
			      that.data.page1_tx_message[16] |= 0x20;
			    }
			    if (that.data.turtle_speed_enable == true) {
			      that.data.page1_tx_message[16] |= 0x01;
			    }
			    if (that.data.default_gear == 4) {
			      that.data.page1_tx_message[16] |= 0x02;
			    }
			    else if (that.data.default_gear == 2) {
			      that.data.page1_tx_message[16] |= 0x04;
			    }
			    else if (that.data.default_gear == 1) {
			      that.data.page1_tx_message[16] |= 0x08;
			    }
			    that.data.page1_tx_message[18] = that.data.softstart_level_index;
			    that.data.page1_tx_message[18]++;
			    that.data.page1_tx_message[19] = that.data.sport_quit_time;
			    that.data.page1_tx_message[20] = that.data.sport_recover_time;
			    that.data.page1_tx_message[21] = that.data.flux_weak_compensate;
			  },
			  get_page2_information: function () {
			    let that = this;
			    let temp;
			    temp = that.data.motor_shift_angle;
			    that.data.page2_tx_message[5] = (temp >> 8) & 0xff;
			    that.data.page2_tx_message[6] = (temp) & 0xff;
			
			    temp = that.data.start_tempretrue_protect_value;
			    that.data.page2_tx_message[7] = (temp) & 0xff;
			
			    temp = that.data.over_temperetrue_protect_value;
			    that.data.page2_tx_message[8] = (temp) & 0xff;
			
			    temp = that.data.max_tempretrue_protect_value;
			    that.data.page2_tx_message[9] = (temp) & 0xff;
			
			    temp = that.data.tempretrue_fact;
			    that.data.page2_tx_message[10] = (temp >> 8) & 0xff;
			    that.data.page2_tx_message[11] = (temp) & 0xff;
			
			    temp = that.data.adj_fact1;
			    that.data.page2_tx_message[12] = (temp >> 8) & 0xff;
			    that.data.page2_tx_message[13] = (temp) & 0xff;
			
			    temp = that.data.adj_fact2;
			    that.data.page2_tx_message[14] = (temp >> 8) & 0xff;
			    that.data.page2_tx_message[15] = (temp) & 0xff;
			
			    temp = that.data.reverse_speed_limit_percent;
			    that.data.page2_tx_message[16] = (temp) & 0xff;
			
			    that.data.page2_tx_message[17] = 0;
			    // temp = page3.m_set_dr.GetCheck();
			
			    if (that.data.set_motor_dir == 2) {
			      that.data.page2_tx_message[17] |= 0x80;
			    }/**/
			    if (that.data.sport_auto_quit_enable == true) {
			      that.data.page2_tx_message[17] |= 0x40;
			    }
			    if (that.data.exchange_hall_flag == true) {
			      that.data.page2_tx_message[17] |= 0x20;
			    }
			    if (that.data.exchange_motor_phase_flag == true) {
			      that.data.page2_tx_message[17] |= 0x10;
			    }
			    //temp = page1.m_park_enalbe.GetCheck();
			    if (that.data.auto_park_enable == true) {
			      that.data.page2_tx_message[17] |= 0x08;
			    }
			    that.data.page2_tx_message[18] = that.data.motor_pole_pair;
			    that.data.page2_tx_message[19] = that.data.ebs_percent;
			    that.data.page2_tx_message[20] = ((that.data.software_vision + 0.009999) * 100) & 0xff;
			    that.data.page2_tx_message[21] = ((that.data.m_hardware_vision + 0.009999) * 100) & 0xff;
			  },
			  get_page3_information: function () {
			    let that = this;
			    let temp;
			    that.data.page3_tx_message[5] = 0;
			    if (that.data.aux_move_enable_flag == true) {
			      that.data.page3_tx_message[5] |= 0x01;
			    }
			    if (that.data.max_speed_limit_enable == true) {
			      that.data.page3_tx_message[5] |= 0x02;
			    }
			    if (that.data.output_type_selcet_value == 1) {
			      that.data.page3_tx_message[5] |= 0x04;
			    }
			    if (that.data.cruise_enable_flag == true) {
			      that.data.page3_tx_message[5] |= 0x08;
			    }
			    if (that.data.double_voltage_enable == true) {
			      that.data.page3_tx_message[5] |= 0x10;
			    }
			    if (that.data.double_voltage_value == 2) {
			      that.data.page3_tx_message[5] |= 0x20;
			    }
			    if (that.data.safe_start_enable_flag == true) {
			      that.data.page3_tx_message[5] |= 0x40;
			    }
			    temp = (that.data.aux_speed_limit_percent * 32768 / 100);
			    that.data.page3_tx_message[6] = (temp >> 8) & 0xff;
			    that.data.page3_tx_message[7] = (temp) & 0xff;
			
			    temp = that.data.aux_torque_limit_value;
			    that.data.page3_tx_message[8] = (temp >> 8) & 0xff;
			    that.data.page3_tx_message[9] = (temp) & 0xff;
			
			    temp = that.data.max_speed_limit_value;
			    that.data.page3_tx_message[10] = (temp >> 8) & 0xff;
			    that.data.page3_tx_message[11] = (temp) & 0xff;
			
			    temp = that.data.low_speed_limit_current_percet;
			    that.data.page3_tx_message[12] = (temp) & 0xff;
			
			    temp = that.data.mid_speed_limit_current_percet;
			    that.data.page3_tx_message[13] = (temp) & 0xff;
			
			    temp = that.data.over_module_percent;
			    that.data.page3_tx_message[14] = (temp) & 0xff;
			
			    temp = that.data.phase_Ki;
			    that.data.page3_tx_message[15] = (temp >> 8) & 0xff;
			    that.data.page3_tx_message[16] = (temp) & 0xff;
			
			    temp = that.data.rated_phase_current_value;
			    that.data.page3_tx_message[17] = (temp >> 8) & 0xff;
			    that.data.page3_tx_message[18] = (temp) & 0xff;
			
			    temp = that.data.rated_phase_current_limit_time;
			    that.data.page3_tx_message[19] = (temp >> 8) & 0xff;
			    that.data.page3_tx_message[20] = (temp) & 0xff;
			
			    that.data.page3_tx_message[21] = that.data.flux_weak_calibration_value;
			  },
			  get_page4_information: function () {
			    let that = this;
			    let temp;
			    let i = 0;
			
			    temp = that.data.function_select_index0;
			    temp |= (that.data.function_select_radiobox0 >> 1) << 9;
			    temp |= (that.data.function_select_checkbox0 & 0x04) << 9;
			    temp |= (that.data.function_select_checkbox0 & 0x03) << 7;
			    that.data.page4_tx_message[5 + i * 2] = (temp >> 8) & 0xff;
			    that.data.page4_tx_message[6 + i * 2] = (temp) & 0xff;
			    i++;
			    temp = that.data.function_select_index1;
			    temp |= (that.data.function_select_radiobox1 >> 1) << 9;
			    temp |= (that.data.function_select_checkbox1 & 0x04) << 9;
			    temp |= (that.data.function_select_checkbox1 & 0x03) << 7;
			    that.data.page4_tx_message[5 + i * 2] = (temp >> 8) & 0xff;
			    that.data.page4_tx_message[6 + i * 2] = (temp) & 0xff;
			    i++;
			    temp = that.data.function_select_index2;
			    temp |= (that.data.function_select_radiobox2 >> 1) << 9;
			    temp |= (that.data.function_select_checkbox2 & 0x04) << 9;
			    temp |= (that.data.function_select_checkbox2 & 0x03) << 7;
			    that.data.page4_tx_message[5 + i * 2] = (temp >> 8) & 0xff;
			    that.data.page4_tx_message[6 + i * 2] = (temp) & 0xff;
			    i++;
			    temp = that.data.function_select_index3;
			    temp |= (that.data.function_select_radiobox3 >> 1) << 9;
			    temp |= (that.data.function_select_checkbox3 & 0x04) << 9;
			    temp |= (that.data.function_select_checkbox3 & 0x03) << 7;
			    that.data.page4_tx_message[5 + i * 2] = (temp >> 8) & 0xff;
			    that.data.page4_tx_message[6 + i * 2] = (temp) & 0xff;
			    i++;
			    temp = that.data.function_select_index4;
			    temp |= (that.data.function_select_radiobox4 >> 1) << 9;
			    temp |= (that.data.function_select_checkbox4 & 0x04) << 9;
			    temp |= (that.data.function_select_checkbox4 & 0x03) << 7;
			    that.data.page4_tx_message[5 + i * 2] = (temp >> 8) & 0xff;
			    that.data.page4_tx_message[6 + i * 2] = (temp) & 0xff;
			    i++;
			    temp = that.data.function_select_index5;
			    temp |= (that.data.function_select_radiobox5 >> 1) << 9;
			    temp |= (that.data.function_select_checkbox5 & 0x04) << 9;
			    temp |= (that.data.function_select_checkbox5 & 0x03) << 7;
			    that.data.page4_tx_message[5 + i * 2] = (temp >> 8) & 0xff;
			    that.data.page4_tx_message[6 + i * 2] = (temp) & 0xff;
			    i++;
			    temp = that.data.function_select_index6;
			    temp |= (that.data.function_select_radiobox6 >> 1) << 9;
			    temp |= (that.data.function_select_checkbox6 & 0x04) << 9;
			    temp |= (that.data.function_select_checkbox6 & 0x03) << 7;
			    that.data.page4_tx_message[5 + i * 2] = (temp >> 8) & 0xff;
			    that.data.page4_tx_message[6 + i * 2] = (temp) & 0xff;
			    i++;
			    temp = that.data.function_select_index7;
			    temp |= (that.data.function_select_radiobox7 >> 1) << 9;
			    temp |= (that.data.function_select_checkbox7 & 0x04) << 9;
			    temp |= (that.data.function_select_checkbox7 & 0x03) << 7;
			    that.data.page4_tx_message[5 + i * 2] = (temp >> 8) & 0xff;
			    that.data.page4_tx_message[6 + i * 2] = (temp) & 0xff;
			    that.data.page4_tx_message[21] = that.data.flux_weak_calibration_value;
			  },
			  get_page5_information: function () {
			    let that = this;
			    let temp;
			    let i = 8;
			    temp = that.data.function_select_index8;
			    temp |= (that.data.function_select_radiobox8 >> 1) << 9;
			    temp |= (that.data.function_select_checkbox8 & 0x04) << 9;
			    temp |= (that.data.function_select_checkbox8 & 0x03) << 7;
			    that.data.page5_tx_message[5 + (i - 8) * 2] = (temp >> 8) & 0xff;
			    that.data.page5_tx_message[6 + (i - 8) * 2] = (temp) & 0xff;
			    i++;
			    temp = that.data.function_select_index9;
			    temp |= (that.data.function_select_radiobox9 >> 1) << 9;
			    temp |= (that.data.function_select_checkbox9 & 0x04) << 9;
			    temp |= (that.data.function_select_checkbox9 & 0x03) << 7;
			    that.data.page5_tx_message[5 + (i - 8) * 2] = (temp >> 8) & 0xff;
			    that.data.page5_tx_message[6 + (i - 8) * 2] = (temp) & 0xff;
			    i++;
			    temp = that.data.function_select_index10;
			    temp |= (that.data.function_select_radiobox10 >> 1) << 9;
			    temp |= (that.data.function_select_checkbox10 & 0x04) << 9;
			    temp |= (that.data.function_select_checkbox10 & 0x03) << 7;
			    that.data.page5_tx_message[5 + (i - 8) * 2] = (temp >> 8) & 0xff;
			    that.data.page5_tx_message[6 + (i - 8) * 2] = (temp) & 0xff;
			    i++;
			    temp = that.data.function_select_index11;
			    temp |= (that.data.function_select_radiobox11 >> 1) << 9;
			    temp |= (that.data.function_select_checkbox11 & 0x04) << 9;
			    temp |= (that.data.function_select_checkbox11 & 0x03) << 7;
			    that.data.page5_tx_message[5 + (i - 8) * 2] = (temp >> 8) & 0xff;
			    that.data.page5_tx_message[6 + (i - 8) * 2] = (temp) & 0xff;
			    i++;
			    temp = that.data.function_select_index12;
			    temp |= (that.data.function_select_radiobox12 >> 1) << 9;
			    temp |= (that.data.function_select_checkbox12 & 0x04) << 9;
			    temp |= (that.data.function_select_checkbox12 & 0x03) << 7;
			    that.data.page5_tx_message[5 + (i - 8) * 2] = (temp >> 8) & 0xff;
			    that.data.page5_tx_message[6 + (i - 8) * 2] = (temp) & 0xff;
			    i++;
			    temp = that.data.function_select_index13;
			    temp |= (that.data.function_select_radiobox13 >> 1) << 9;
			    temp |= (that.data.function_select_checkbox13 & 0x04) << 9;
			    temp |= (that.data.function_select_checkbox13 & 0x03) << 7;
			    that.data.page5_tx_message[5 + (i - 8) * 2] = (temp >> 8) & 0xff;
			    that.data.page5_tx_message[6 + (i - 8) * 2] = (temp) & 0xff;
			    i++;
			    temp = that.data.function_select_index14;
			    temp |= (that.data.function_select_radiobox14 >> 1) << 9;
			    temp |= (that.data.function_select_checkbox14 & 0x04) << 9;
			    temp |= (that.data.function_select_checkbox14 & 0x03) << 7;
			    that.data.page5_tx_message[5 + (i - 8) * 2] = (temp >> 8) & 0xff;
			    that.data.page5_tx_message[6 + (i - 8) * 2] = (temp) & 0xff;
			    i++;
			    temp = that.data.function_select_index15;
			    temp |= (that.data.function_select_radiobox15 >> 1) << 9;
			    temp |= (that.data.function_select_checkbox15 & 0x04) << 9;
			    temp |= (that.data.function_select_checkbox15 & 0x03) << 7;
			    that.data.page5_tx_message[5 + (i - 8) * 2] = (temp >> 8) & 0xff;
			    that.data.page5_tx_message[6 + (i - 8) * 2] = (temp) & 0xff;
			  },
			  get_page6_information: function () {
			    let that = this;
			
			    that.data.page6_tx_message[5] = (that.data.footplat_start_value * 255 / 5.5) & 0xff;
			    that.data.page6_tx_message[6] = (that.data.footplat_end_value * 255 / 5.5) & 0xff;
			    that.data.page6_tx_message[7] = (that.data.footplat_low_protect_value * 255 / 5.5) & 0xff;
			    that.data.page6_tx_message[8] = (that.data.footplat_high_protect_value * 255 / 5.5) & 0xff;
			
			    that.data.page6_tx_message[9] = that.data.sink_ratio & 0xff;
			    that.data.page6_tx_message[10] = that.data.rise_ratio & 0xff;
			    that.data.page6_tx_message[11] = (that.data.start_torque >> 8) & 0xff;
			    that.data.page6_tx_message[12] = (that.data.start_torque) & 0xff;
			    that.data.page6_tx_message[13] = (that.data.combine_torque >> 8) & 0xff;
			    that.data.page6_tx_message[14] = (that.data.combine_torque) & 0xff;
			  },
			 save_confg: function () {
			    let that = this;
			
			    let BUFFERSIZE = 24;
			    let i;
			    let str_temp;
			    let str = "";
			    that.get_page0_information();
			    that.get_page1_information();
			    that.get_page2_information();
			    that.get_page3_information();
			    that.get_page4_information();
			    that.get_page5_information();
			    that.get_page6_information();
			
			    wx.getSavedFileList({
			      success(res) {
			        if (res.fileList.length > 0) {
			          wx.removeSavedFile({
			            filePath: res.fileList[0].filePath,
			            complete(res) {
			              console.log(res)
			            }
			          })
			        }
			      }
			    })
			    setTimeout(function () {
			
			    }, 100);
			    for (i = 5; i < BUFFERSIZE - 2; i++) {
			      str_temp = (that.data.page0_tx_message[i] & 0xff).toString() + "\r\n";
			      str += str_temp;
			    }
			    for (i = 5; i < BUFFERSIZE - 2; i++) {
			      str_temp = (that.data.page1_tx_message[i] & 0xff).toString() + "\r\n";
			      str += str_temp;
			    }
			    for (i = 5; i < BUFFERSIZE - 2; i++) {
			      str_temp = (that.data.page2_tx_message[i] & 0xff).toString() + "\r\n";
			      str += str_temp;
			    }
			    for (i = 5; i < BUFFERSIZE - 2; i++) {
			      str_temp = (that.data.page3_tx_message[i] & 0xff).toString() + "\r\n";
			      str += str_temp;
			    }
			    for (i = 5; i < BUFFERSIZE - 2; i++) {
			      str_temp = (that.data.page4_tx_message[i] & 0xff).toString() + "\r\n";
			      str += str_temp;
			      console.log(str_temp + that.data.page4_tx_message[i])
			    }
			    for (i = 5; i < BUFFERSIZE - 2; i++) {
			      str_temp = (that.data.page5_tx_message[i] & 0xff).toString() + "\r\n";
			      str += str_temp;
			      console.log(str_temp + that.data.page5_tx_message[i])
			    }
			    for (i = 5; i < BUFFERSIZE - 2; i++) {
			      str_temp = (that.data.page6_tx_message[i] & 0xff).toString() + "\r\n";
			      str += str_temp;
			    }
			
			    var date = new Date();
			    let str_date = utils.dateFtt(date);
			    that.data.inifile_path = wx.env.USER_DATA_PATH + "/" + str_date + ".ini";
			    const fs = wx.getFileSystemManager()
			    fs.writeFile({
			      filePath: that.data.inifile_path,
			      data: str,
			      encoding: 'utf8',
			      success(res) {
			        console.log(res)
			      },
			      fail(res) {
			        console.error(res)
			      }
			    })
			  },
			import_pararm_config(file_res) {
			    let that = this;
			    let k = 0,
			      j, n;
			    let BUFFERSIZE = 24;
			    let RxBuffer = new Uint8Array(24);
			    let str = file_res.split("\r\n");
			    for (j = 1; j < 8; j++) {
			      RxBuffer[4] = j;
			      for (n = 5; n < BUFFERSIZE - 2; n++) {
			
			        RxBuffer[n] = parseInt(str[k++]);
			      }
			      that.information_update(RxBuffer);
			
			    }
			},
			 information_update: function (RxBuffer) {
			    var that = this;
			    var BUFFERSIZE = 24;
			    var temp = 0;
			    switch (RxBuffer[4]) {
			      case 1: {
			        if (RxBuffer[5] == 0x05) {
			          temp = 0;
			        } else if (RxBuffer[5] == 0x0A) {
			          temp = 1;
			        } else if (RxBuffer[5] == 0x14) {
			          temp = 2;
			        } else if (RxBuffer[5] == 0x1e) {
			          temp = 3;
			        } else if (RxBuffer[5] == 0x28) {
			          temp = 4;
			        }
			        that.setData({
			          pm_type_index: temp
			        });
			        that.setData({
			          voltage_level_index: (RxBuffer[6] & 0xf)
			        });
			        that.setData({
			          manufacturer_code_index: ((RxBuffer[6] >> 4) & 0xf)
			        });
			        that.setData({
			          over_voltage_value: (RxBuffer[7] << 8 | RxBuffer[8]) / 10
			        });
			        that.setData({
			          under_voltage_value: (RxBuffer[16] << 8 | RxBuffer[17]) / 10
			        });
			        that.setData({
			          soft_under_voltage_value: (RxBuffer[9] << 8 | RxBuffer[10]) / 10
			        });
			        that.setData({
			          under_voltage_threshold_value: (RxBuffer[11]) / 10
			        });
			        that.setData({
			          bus_current_limit_value: (RxBuffer[12] << 8 | RxBuffer[13])
			        });
			        that.setData({
			          phase_current_value: (RxBuffer[14] << 8 | RxBuffer[15])
			        });
			        that.setData({
			          vol_calibration_value: (RxBuffer[18] << 8 | RxBuffer[19])
			        });
			        that.setData({
			          cur_calibration_value: (RxBuffer[20] << 8 | RxBuffer[21])
			        });
				
			        console.log("页面1读取完成",this.data)
			      }
			      break;
			    case 2: {
			
			      temp = (RxBuffer[5] << 8 | RxBuffer[6]);
			      that.setData({
			        sport_bus_current_limit: temp
			      });
			
			      temp = (RxBuffer[7]);
			      that.setData({
			        low_speed_percent: temp
			      });
			
			      temp = (RxBuffer[8]);
			      that.setData({
			        mid_speed_percent: temp
			      });
			
			      temp = (RxBuffer[9]);
			      that.setData({
			        high_speed_percent: temp
			      });
			
			      temp = (RxBuffer[10] << 8 | RxBuffer[11]);
			      that.setData({
			        flux_weak_value: temp
			      });
			
			      temp = (RxBuffer[12] << 8 | RxBuffer[13]);
			      that.setData({
			        phase_Kp: temp
			      });
			
			      temp = (RxBuffer[14] << 8 | RxBuffer[15]);
			      that.setData({
			        phase_current_limit_value: temp
			      });
			
			      temp = (RxBuffer[17]);
			      that.setData({
			        turtle_speed_pecent: temp
			      });
			
			      if ((RxBuffer[16] & 0x80) != 0) {
			        //page1.m_soft_start_enable.SetCheck(1);
			        that.setData({
			          soft_start_flag: true
			        });
			      } else {
			        //page1.m_soft_start_enable.SetCheck(0);
			        that.setData({
			          soft_start_flag: false
			        });
			      }
			      if ((RxBuffer[16] & 0x40) != 0) {
			        //page3.m_low_ebreak_enable.SetCheck(1);
			        that.setData({
			          motor_noise_forbid_falg: true
			        });
			      } else {
			        //page3.m_low_ebreak_enable.SetCheck(0);
			        that.setData({
			          motor_noise_forbid_falg: false
			        });
			      }
			      if ((RxBuffer[16] & 0x20) != 0) {
			        //page1.m_self_lock_switch_enable = 1;
			        //that.setData({safe_start_enable_flag:true});
			      } else {
			        //page1.m_self_lock_switch_enable = 0;
			        //that.setData({safe_start_enable_flag:false});
			      }
			      if ((RxBuffer[16] & 0x10) != 0) {
			        //page3.m_v_type_flag = 1;
			        that.setData({
			          motor_type_selcet_value: 2
			        });
			      } else {
			        //page3.m_v_type_flag = 0;
			        that.setData({
			          motor_type_selcet_value: 1
			        });
			      }
			      if ((RxBuffer[16] & 0x20) != 0) {
			        //page3.m_v_type_flag = 1;
			        that.setData({
			          dot_switch_selcet_flag: 2
			        });
			      } else {
			        //page3.m_v_type_flag = 0;
			        that.setData({
			          dot_switch_selcet_flag: 1
			        });
			      }
			      if ((RxBuffer[16] & 0x01) != 0) {
			        //page1.m_speed_limit_enable.SetCheck(1);
			        that.setData({
			          turtle_speed_enable: true
			        });
			      } else {
			        //page1.m_speed_limit_enable.SetCheck(0);
			        that.setData({
			          turtle_speed_enable: false
			        });
			      }
			      if ((RxBuffer[16] & 0x08) != 0) {
			        //	page1.m_default_speed_value = 0;
			        that.setData({
			          default_gear: 1
			        });
			      } else if ((RxBuffer[16] & 0x04) != 0) {
			        //page1.m_default_speed_value = 1;
			        that.setData({
			          default_gear: 2
			        });
			      } else if ((RxBuffer[16] & 0x02) != 0) {
			        //page1.m_default_speed_value = 2;
			        that.setData({
			          default_gear: 4
			        });
			      }
			      if (RxBuffer[18] < 17) {
			        //page1.m_soft_start_level.SetCurSel(RxBuffer[18] - 1);
			        that.setData({
			          softstart_level_index: RxBuffer[18] - 1
			        });
			      } else {
			        that.setData({
			          softstart_level_index: 0
			        });
			      }
			      console.log(RxBuffer[18])
			      //page1.m_boost_time_limit_value = (RxBuffer[19]);
			      that.setData({
			        sport_quit_time: (RxBuffer[19])
			      });
			
			      //page1.m_boost_time_recover_value = (RxBuffer[20]);
			      that.setData({
			        sport_recover_time: (RxBuffer[20])
			      });
			      //page1.m_flux_weak_param_value = RxBuffer[21];
			      that.setData({
			        flux_weak_compensate: (RxBuffer[21])
			      });
			      console.log("页面2读取完成",this.data)
			    }
			    break;
			    case 3: {
			      temp = (RxBuffer[5] << 8 | RxBuffer[6]);
			      //page3.m_hall_shift_value = temp;
			      let value = new Int16Array(1);
			      value[0] = temp;
			      that.setData({
			        motor_shift_angle: value[0]
			      });
			      //page3.m_start_tempretrue_protect_value = RxBuffer[7];
			      that.setData({
			        start_tempretrue_protect_value: RxBuffer[7]
			      });
			      //page3.m_over_temperetrue_protect_value = RxBuffer[8];
			      that.setData({
			        over_temperetrue_protect_value: RxBuffer[8]
			      });
			      //page3.m_max_tempretrue_protect_value = RxBuffer[9];
			      that.setData({
			        max_tempretrue_protect_value: RxBuffer[9]
			      });
			      temp = (RxBuffer[10] << 8 | RxBuffer[11]);
			      //page3.m_tempretrue_fact1 = temp;
			      that.setData({
			        tempretrue_fact: temp
			      });
			      temp = (RxBuffer[12] << 8 | RxBuffer[13]);
			      //page3.m_tempretrue_fact2 = temp;
			      that.setData({
			        adj_fact1: temp
			      });
			      temp = (RxBuffer[14] << 8 | RxBuffer[15]);
			      //page3.m_tempretrue_fact3 = temp;
			      that.setData({
			        adj_fact2: temp
			      });
			      if ((RxBuffer[17] & 0x80) != 0) {
			        that.setData({
			          set_motor_dir: 2
			        });
			      } else {
			        that.setData({
			          set_motor_dir: 1
			        });
			      }
			      if ((RxBuffer[17] & 0x40) != 0) {
			        //	page1.m_sport_auto_quit_enable.SetCheck(1);
			        that.setData({
			          sport_auto_quit_enable: true
			        });
			      } else {
			        //page1.m_sport_auto_quit_enable.SetCheck(0);
			        that.setData({
			          sport_auto_quit_enable: false
			        });
			      }
			      if ((RxBuffer[17] & 0x20) != 0) {
			        //page3.m_hall_changed.SetCheck(1);
			        that.setData({
			          exchange_hall_flag: true
			        });
			      } else {
			        //page3.m_hall_changed.SetCheck(0);
			        that.setData({
			          exchange_hall_flag: false
			        });
			      }
			      if ((RxBuffer[17] & 0x10) != 0) {
			        //page3.m_phase_changed.SetCheck(1);
			        that.setData({
			          exchange_motor_phase_flag: true
			        });
			      } else {
			        //page3.m_phase_changed.SetCheck(0);
			        that.setData({
			          exchange_motor_phase_flag: false
			        });
			      }
			      if ((RxBuffer[17] & 0x08) != 0) {
			        //page1.m_park_enalbe.SetCheck(1);
			        that.setData({
			          auto_park_enable: true
			        });
			      } else {
			        //page1.m_park_enalbe.SetCheck(0);
			        that.setData({
			          auto_park_enable: false
			        });
			      }
			      //	page3.m_reverse_speed_limit_value = RxBuffer[16];
			      that.setData({
			        reverse_speed_limit_percent: RxBuffer[16]
			      });
			
			      //page3.m_motor_pair = RxBuffer[18];
			      that.setData({
			        motor_pole_pair: RxBuffer[18]
			      });
			      //page3.m_ebs_value = RxBuffer[19];
			      that.setData({
			        ebs_percent: RxBuffer[19]
			      });
			      //page0.m_software_vision = RxBuffer[20];
			      //page0.m_software_vision /= 100;
			      that.setData({
			        software_vision: RxBuffer[20] / 100
			      });
			      //page0.m_hardware_vision = RxBuffer[21];
			      //page0.m_hardware_vision /= 100;
			      that.setData({
			        m_hardware_vision: RxBuffer[21] / 100
			      });
			      console.log("页面3读取完成",this.data)
			    }
			    break;
			    case 4: {
			      if ((RxBuffer[5] & 0x01) != 0) {
			        //page3.m_aux_torque_enable.SetCheck(1);
			        that.setData({
			          aux_move_enable_flag: true
			        });
			      } else {
			        //page3.m_aux_torque_enable.SetCheck(0);
			        that.setData({
			          aux_move_enable_flag: false
			        });
			      }
			      if ((RxBuffer[5] & 0x02) != 0) {
			        //page1.m_hill_down_enalbe.SetCheck(1);
			        that.setData({
			          max_speed_limit_enable: true
			        });
			      } else {
			        //page1.m_hill_down_enalbe.SetCheck(0);
			        that.setData({
			          max_speed_limit_enable: false
			        });
			      }
			      if ((RxBuffer[5] & 0x04) != 0) {
			        //page3.m_output_select_flag = 0;
			        that.setData({
			          output_type_selcet_value: 1
			        });
			      } else {
			        //page3.m_output_select_flag = 1;
			        that.setData({
			          output_type_selcet_value: 2
			        });
			      }
			      if ((RxBuffer[5] & 0x08) != 0) {
			        //page3.m_cruise_enable.SetCheck(1);
			        that.setData({
			          cruise_enable_falg: true
			        });
			      } else {
			        //page3.m_cruise_enable.SetCheck(0);
			        that.setData({
			          cruise_enable_falg: false
			        });
			      }
			      if ((RxBuffer[5] & 0x10) != 0) {
			        //page3.m_double_voltage_enable.SetCheck(1);
			        that.setData({
			          double_voltage_enable: true
			        });
			      } else {
			        //page3.m_double_voltage_enable.SetCheck(0);
			        that.setData({
			          double_voltage_enable: false
			        });
			      }
			      if ((RxBuffer[5] & 0x20) != 0) {
			        //page3.m_double_voltage_select = true;
			        that.setData({
			          double_voltage_value: 2
			        });
			      } else {
			        //page3.m_double_voltage_select = false;
			        that.setData({
			          double_voltage_value: 1
			        });
			      }
			      if ((RxBuffer[5] & 0x40) != 0) {
			        //page3.m_safe_start_vaild.SetCheck(1);
			        that.setData({
			          safe_start_enable_flag: true
			        });
			      } else {
			        //page3.m_safe_start_vaild.SetCheck(0);
			        that.setData({
			          safe_start_enable_flag: false
			        });
			      }
			      temp = (RxBuffer[8] << 8 | RxBuffer[9]);
			      //page3.m_aux_torque_limit_value = temp;
			      that.setData({
			        aux_torque_limit_value: temp
			      });
			      temp = (RxBuffer[6] << 8 | RxBuffer[7]);
			      //page3.m_aux_speed_limit_value = ((temp * 100 + 99) / 32768);
			      that.setData({
			        aux_speed_limit_percent: ((temp * 100 + 99) / 32768)
			      });
			
			      temp = (RxBuffer[10] << 8 | RxBuffer[11]);
			      //page1.m_DH_SP_VALUE = temp;
			      that.setData({
			        max_speed_limit_value: temp
			      });
			
			      temp = (RxBuffer[12]);
			      //page1.m_h_egear_1_value = temp;
			      that.setData({
			        low_speed_limit_current_percet: temp
			      });
			
			      temp = (RxBuffer[13]);
			      //page1.m_h_egear_2_value = temp;
			      that.setData({
			        mid_speed_limit_current_percet: temp
			      });
			
			      temp = (RxBuffer[14]);
			      //page1.m_h_egear_3_value = temp;
			      that.setData({
			        over_module_percent: temp
			      });
			
			      temp = (RxBuffer[15] << 8 | RxBuffer[16]);
			      //page1.m_h_s_gear_flux_weak_value = temp;
			      that.setData({
			        phase_Ki: temp
			      });
			
			      temp = (RxBuffer[17] << 8 | RxBuffer[18]);
			      //page1.m_h_egear_3_flux_weak_value = temp;
			      that.setData({
			        rated_phase_current_value: temp
			      });
			
			      temp = (RxBuffer[19] << 8 | RxBuffer[20]);
			      //page1.m_h_egear_2_flux_weak_value = temp;
			      that.setData({
			        rated_phase_current_limit_time: temp
			      });
			      console.log("页面4读取完成",this.data)
			    }
			    break;
			    case 5: {
			      /*union_IO_setup temp});
			      for (let i:0}); i<8}); i++)
			      {
			        temp.IO_setup_byte:(RxBuffer[5 + i * 2] << 8 | RxBuffer[6 + i * 2])});
			        (CComboBox *)(*ptr_function_list_tab[i]).SetCurSel(temp.IO_setup_bit.function)});
			        *ptr_input_status_value_tab[i]:temp.IO_setup_bit.input_status_set});
			        (*ptr_input_select_tab[i]).SetCheck(temp.IO_setup_bit.input_output)});
			        (*ptr_SW_select_tab[i]).SetCheck(temp.IO_setup_bit.switch_butten)});
			        (*ptr_low_active_select_tab[i]).SetCheck(temp.IO_setup_bit.active_low)});
			      }*/
			      let i = 0;
			      temp = (RxBuffer[5 + i * 2] << 8 | RxBuffer[6 + i * 2])
			      that.setData({
			        function_select_index0: temp & 0x7f
			      });
			      that.setData({
			        function_select_radiobox0: 1 << ((temp >> 9) & 0x03)
			      });
			      that.setData({
			        function_select_checkbox0: ((temp >> 7) & 0x03) + ((temp >> 9) & 0x04)
			      });
			      i++;
			      temp = (RxBuffer[5 + i * 2] << 8 | RxBuffer[6 + i * 2])
			      that.setData({
			        function_select_index1: temp & 0x7f
			      });
			      that.setData({
			        function_select_radiobox1: 1 << ((temp >> 9) & 0x03)
			      });
			      that.setData({
			        function_select_checkbox1: ((temp >> 7) & 0x03) + ((temp >> 9) & 0x04)
			      });
			      i++;
			      temp = (RxBuffer[5 + i * 2] << 8 | RxBuffer[6 + i * 2])
			      that.setData({
			        function_select_index2: temp & 0x7f
			      });
			      that.setData({
			        function_select_radiobox2: 1 << ((temp >> 9) & 0x03)
			      });
			      that.setData({
			        function_select_checkbox2: ((temp >> 7) & 0x03) + ((temp >> 9) & 0x04)
			      });
			      i++;
			      temp = (RxBuffer[5 + i * 2] << 8 | RxBuffer[6 + i * 2])
			      that.setData({
			        function_select_index3: temp & 0x7f
			      });
			      that.setData({
			        function_select_radiobox3: 1 << ((temp >> 9) & 0x03)
			      });
			      that.setData({
			        function_select_checkbox3: ((temp >> 7) & 0x03) + ((temp >> 9) & 0x04)
			      });
			      i++;
			      temp = (RxBuffer[5 + i * 2] << 8 | RxBuffer[6 + i * 2])
			      that.setData({
			        function_select_index4: temp & 0x7f
			      });
			      that.setData({
			        function_select_radiobox4: 1 << ((temp >> 9) & 0x03)
			      });
			      that.setData({
			        function_select_checkbox4: ((temp >> 7) & 0x03) + ((temp >> 9) & 0x04)
			      });
			      i++;
			      temp = (RxBuffer[5 + i * 2] << 8 | RxBuffer[6 + i * 2])
			      that.setData({
			        function_select_index5: temp & 0x7f
			      });
			      that.setData({
			        function_select_radiobox5: 1 << ((temp >> 9) & 0x03)
			      });
			      that.setData({
			        function_select_checkbox5: ((temp >> 7) & 0x03) + ((temp >> 9) & 0x04)
			      });
			      i++;
			      temp = (RxBuffer[5 + i * 2] << 8 | RxBuffer[6 + i * 2])
			      that.setData({
			        function_select_index6: temp & 0x7f
			      });
			      that.setData({
			        function_select_radiobox6: 1 << ((temp >> 9) & 0x03)
			      });
			      that.setData({
			        function_select_checkbox6: ((temp >> 7) & 0x03) + ((temp >> 9) & 0x04)
			      });
			      i++;
			      temp = (RxBuffer[5 + i * 2] << 8 | RxBuffer[6 + i * 2])
			      that.setData({
			        function_select_index7: temp & 0x7f
			      });
			      that.setData({
			        function_select_radiobox7: 1 << ((temp >> 9) & 0x03)
			      });
			      that.setData({
			        function_select_checkbox7: ((temp >> 7) & 0x03) + ((temp >> 9) & 0x04)
			      });
			      //flux_weak_calibration_value:RxBuffer[21]});
			      that.setData({
			        flux_weak_calibration_value: RxBuffer[21]
			      });
			      if( that.data.function_select_index0==54 || that.data.function_select_index0==56
			        || that.data.function_select_index1==54 || that.data.function_select_index1==56
			        || that.data.function_select_index2==54 || that.data.function_select_index2==56
			        || that.data.function_select_index3==54 || that.data.function_select_index3==56
			        || that.data.function_select_index4==54 || that.data.function_select_index4==56
			        || that.data.function_select_index5==54 || that.data.function_select_index5==56
			        || that.data.function_select_index6==54 || that.data.function_select_index6==56
			        || that.data.function_select_index7==54 || that.data.function_select_index7==56
			        || that.data.function_select_index8==54 || that.data.function_select_index8==56
			        || that.data.function_select_index9==54 || that.data.function_select_index9==56 
			        || that.data.function_select_index10==54 || that.data.function_select_index10==56
			        || that.data.function_select_index11==54 || that.data.function_select_index11==56
			        || that.data.function_select_index12==54 || that.data.function_select_index12==56
			        || that.data.function_select_index13==54 || that.data.function_select_index13==56
			        || that.data.function_select_index14==54 || that.data.function_select_index14==56
			        || that.data.function_select_index15==54 || that.data.function_select_index15==56 )
			        {
			          that.setData({
			            footplat_show_mode:false
			            })
			        }
			        else
			        {
			          that.setData({
			            footplat_show_mode:true
			            })
			        }     
			      console.log("页面5读取完成",this.data)
			    }
			    break;
			    case 6: {
			      /*union_IO_setup temp});
			  
			        for (int i:8}); i<16}); i++)
			        {
			          temp.IO_setup_byte:(RxBuffer[5 + (i - 8) * 2] << 8 | RxBuffer[6 + (i - 8) * 2])});
			          (CComboBox *)(*ptr_function_list_tab[i]).SetCurSel(temp.IO_setup_bit.function)});
			          *ptr_input_status_value_tab[i]:temp.IO_setup_bit.input_status_set});
			          (*ptr_input_select_tab[i]).SetCheck(temp.IO_setup_bit.input_output)});
			          (*ptr_SW_select_tab[i]).SetCheck(temp.IO_setup_bit.switch_butten)});
			          (*ptr_low_active_select_tab[i]).SetCheck(temp.IO_setup_bit.active_low)});
			        }
			        
			        _m_can_burad:RxBuffer[21] >> 4});
			        _m_can_ID:RxBuffer[21] & 0xf});
			        for (int i:5}); i<BUFFERSIZE - 2}); i++)
			        {
			          page5_tx_message[i]&0xff):RxBuffer[i]});
			        }*/
			      let i = 8;
			      temp = (RxBuffer[5 + (i - 8) * 2] << 8 | RxBuffer[6 + (i - 8) * 2])
			      that.setData({
			        function_select_index8: temp & 0x7f
			      });
			      that.setData({
			        function_select_radiobox8: 1 << ((temp >> 9) & 0x03)
			      });
			      that.setData({
			        function_select_checkbox8: ((temp >> 7) & 0x03) + ((temp >> 9) & 0x04)
			      });
			      i++;
			      temp = (RxBuffer[5 + (i - 8) * 2] << 8 | RxBuffer[6 + (i - 8) * 2])
			      that.setData({
			        function_select_index9: temp & 0x7f
			      });
			      that.setData({
			        function_select_radiobox9: 1 << ((temp >> 9) & 0x03)
			      });
			      that.setData({
			        function_select_checkbox9: ((temp >> 7) & 0x03) + ((temp >> 9) & 0x04)
			      });
			      i++;
			      temp = (RxBuffer[5 + (i - 8) * 2] << 8 | RxBuffer[6 + (i - 8) * 2])
			      that.setData({
			        function_select_index10: temp & 0x7f
			      });
			      that.setData({
			        function_select_radiobox10: 1 << ((temp >> 9) & 0x03)
			      });
			      that.setData({
			        function_select_checkbox10: ((temp >> 7) & 0x03) + ((temp >> 9) & 0x04)
			      });
			      i++;
			      temp = (RxBuffer[5 + (i - 8) * 2] << 8 | RxBuffer[6 + (i - 8) * 2])
			      that.setData({
			        function_select_index11: temp & 0x7f
			      });
			      that.setData({
			        function_select_radiobox11: 1 << ((temp >> 9) & 0x03)
			      });
			      that.setData({
			        function_select_checkbox11: ((temp >> 7) & 0x03) + ((temp >> 9) & 0x04)
			      });
			      i++;
			      temp = (RxBuffer[5 + (i - 8) * 2] << 8 | RxBuffer[6 + (i - 8) * 2])
			      that.setData({
			        function_select_index12: temp & 0x7f
			      });
			      that.setData({
			        function_select_radiobox12: 1 << ((temp >> 9) & 0x03)
			      });
			      that.setData({
			        function_select_checkbox12: ((temp >> 7) & 0x03) + ((temp >> 9) & 0x04)
			      });
			      i++;
			      temp = (RxBuffer[5 + (i - 8) * 2] << 8 | RxBuffer[6 + (i - 8) * 2])
			      that.setData({
			        function_select_index13: temp & 0x7f
			      });
			      that.setData({
			        function_select_radiobox13: 1 << ((temp >> 9) & 0x03)
			      });
			      that.setData({
			        function_select_checkbox13: ((temp >> 7) & 0x03) + ((temp >> 9) & 0x04)
			      });
			      i++;
			      temp = (RxBuffer[5 + (i - 8) * 2] << 8 | RxBuffer[6 + (i - 8) * 2])
			      that.setData({
			        function_select_index14: temp & 0x7f
			      });
			      that.setData({
			        function_select_radiobox14: 1 << ((temp >> 9) & 0x03)
			      });
			      that.setData({
			        function_select_checkbox14: ((temp >> 7) & 0x03) + ((temp >> 9) & 0x04)
			      });
			      i++;
			      temp = (RxBuffer[5 + (i - 8) * 2] << 8 | RxBuffer[6 + (i - 8) * 2])
			      that.setData({
			        function_select_index15: temp & 0x7f
			      });
			      that.setData({
			        function_select_radiobox15: 1 << ((temp >> 9) & 0x03)
			      });
			      that.setData({
			        function_select_checkbox15: ((temp >> 7) & 0x03) + ((temp >> 9) & 0x04)
			      });
			      if( that.data.function_select_index0==54 || that.data.function_select_index0==56
			        || that.data.function_select_index1==54 || that.data.function_select_index1==56
			        || that.data.function_select_index2==54 || that.data.function_select_index2==56
			        || that.data.function_select_index3==54 || that.data.function_select_index3==56
			        || that.data.function_select_index4==54 || that.data.function_select_index4==56
			        || that.data.function_select_index5==54 || that.data.function_select_index5==56
			        || that.data.function_select_index6==54 || that.data.function_select_index6==56
			        || that.data.function_select_index7==54 || that.data.function_select_index7==56
			        || that.data.function_select_index8==54 || that.data.function_select_index8==56
			        || that.data.function_select_index9==54 || that.data.function_select_index9==56 
			        || that.data.function_select_index10==54 || that.data.function_select_index10==56
			        || that.data.function_select_index11==54 || that.data.function_select_index11==56
			        || that.data.function_select_index12==54 || that.data.function_select_index12==56
			        || that.data.function_select_index13==54 || that.data.function_select_index13==56
			        || that.data.function_select_index14==54 || that.data.function_select_index14==56
			        || that.data.function_select_index15==54 || that.data.function_select_index15==56 )
			        {
			          that.setData({
			            footplat_show_mode:false
			            })
			        }
			        else
			        {
			          that.setData({
			            footplat_show_mode:true
			            })
			        }
			
			      console.log("页面6读取完成",this.data)
			    }
			    break;
			    case 7: {
			      //page0.m_footplat_start_value = floor((RxBuffer[5] * 550 / 255) + 2.2) / 100;
			      that.setData({
			        footplat_start_value: Math.floor((RxBuffer[5] * 550 / 255) + 2.2) / 100
			      });
			      //page0.m_footplat_end_value = floor((RxBuffer[6] * 550 / 255) + 2.2) / 100;
			      that.setData({
			        footplat_end_value: Math.floor((RxBuffer[6] * 550 / 255) + 2.2) / 100
			      });
			      //page0.m_footplat_low_protect_value = floor((RxBuffer[7] * 550 / 255) + 2.2) / 100;
			      that.setData({
			        footplat_low_protect_value: Math.floor((RxBuffer[7] * 550 / 255) + 2.2) / 100
			      });
			      //page0.m_footplat_high_protect_value = floor((RxBuffer[8] * 550 / 255) + 2.2) / 100;
			      that.setData({
			        footplat_high_protect_value: Math.floor((RxBuffer[8] * 550 / 255) + 2.2) / 100
			      });
			      //page0.m_sink_ratio = RxBuffer[9];
			      that.setData({
			        sink_ratio: RxBuffer[9]
			      });
			      //page0.m_rise_ratio = RxBuffer[10];
			      that.setData({
			        rise_ratio: RxBuffer[10]
			      });
			      //page0.m_start_torque = (RxBuffer[11] << 8 | RxBuffer[12]);
			      that.setData({
			        start_torque: (RxBuffer[11] << 8 | RxBuffer[12])
			      });
			      //page0.m_combine_torque = (RxBuffer[13] << 8 | RxBuffer[14]);
			      that.setData({
			        combine_torque: (RxBuffer[13] << 8 | RxBuffer[14])
			      });
			      //calibration_value_show_flag = true;
			      console.log("页面7读取完成",this.data)
			    }
			    break;
			    default:
			      console.log("未知页面！！！")
			      break;
			    }
			  },
			save_data(){
				if(this.dev_name == ""){
					uni.showToast({
						title: '设备名称必填',
						icon:"none"
					})
					return;
				}
				
				var data = uni.getStorageSync('dev_data');
				console.log(data,77777777777)
				
				let _this = this;
				let deviceInfo = uni.getStorageSync('deviceInfo');
				let serviceInfo = uni.getStorageSync('serviceInfo');
				let send_dat = {
					title:this.dev_name,
					dev_uid:deviceInfo.deviceId,
					server_uid:serviceInfo.uuid,
					is_lan:0,
					mode_lan:this.lan_bug,
					is_pri:this.is_pri,
					is_yuancheng:this.is_yuancheng
					
				}
				uni.showLoading({
					title: 'loading',
					mask:true
				});
				
				this.$api.request('/api/user/baocun',
								{
									
									data:data,
									send_dat:send_dat,
									deviceInfo:deviceInfo,
									serviceInfo:serviceInfo,
									}, '', function(res){
					 uni.hideLoading(); //隐藏loading
					 uni.showToast({
					 	title: '保存成功',
					 	icon:"none"
					 })
				
				});
			},
			baocun(){
				if (app.globalData.connected != true) {
					if(this.lang==0){
						uni.showToast({
							title: '需要先连接蓝牙',
							icon:"none"
						})
					}else{
						uni.showToast({
							title: 'Bluetooth needs to be connected first',
							icon:"none"
						})
					}
					return;
				}
				
				this.is_yuancheng = app.globalData.is_yuancheng;
				this.$refs.popup1.open();
				
				
				
				return;
				
				
				if (app.globalData.connected != true) {
					if(this.lang==0){
						uni.showToast({
							title: '需要先连接蓝牙',
							icon:"none"
						})
					}else{
						uni.showToast({
							title: 'Bluetooth needs to be connected first',
							icon:"none"
						})
					}
					return;
				}
				var data = uni.getStorageSync('dev_data');
				
				let _this = this;
				
				
				let deviceInfo = uni.getStorageSync('deviceInfo');
				let serviceInfo = uni.getStorageSync('serviceInfo');
				let send_dat = {
					title:deviceInfo.name,
					dev_uid:deviceInfo.deviceId,
					server_uid:serviceInfo.uuid,
					is_lan:0,
					mode_lan:this.lan_bug,
				}
				uni.showLoading({
					title: 'loading',
					mask:true
				});
				this.$api.request('/api/user/baocun',{data:data,send_dat:send_dat,deviceInfo:deviceInfo,serviceInfo:serviceInfo}, '', function(res){
					 uni.hideLoading(); //隐藏loading
					 uni.showToast({
					 	title: 'success',
					 	icon:"none"
					 })
				
				});
			},
			cs_openPicker(type) {
					this.$refs.cs_picker.open();
			},
			cs_confirm(e){
				  // 
				   console.log(555,e)
				 var index = e.indexs[0];var index = e.indexs[0];
				  // this.ble_moden_value = index;
				  this.lan_bug = index
				  uni.setStorageSync('lan_bug',index)
				  
			},
			lang_openPicker(type) {
					this.$refs.lang_picker.open();
			},
			lang_confirm(e){
				  // 
				   console.log(555,e)
				 var index = e.indexs[0];var index = e.indexs[0];
				  // this.ble_moden_value = index;
				  this.lang = index
				  uni.setStorageSync('lang',index)
			},
			get_user_info(){
				uni.showLoading({
					title: 'loading',
					mask:true
				});
				//登陆
					let _this = this;
					this.$api.request('/api/user/getUserInfo', {}, '', function(res){
						
						
						console.log(res);
						 uni.hideLoading(); //隐藏loading
						if(res.code == 1) {
							_this.userinfo = res.data
							uni.setStorageSync('userinfo', res.data);
							console.log(_this.userinfo,777)
						}else{
							uni.showToast({
								title: res.msg,
								icon:"none"
							})
						}
					});
			},
			goDetail(url) {
				console.log(88888888888,url)
				
				uni.navigateTo({
					url: url
				})
				
			},
		}
	}
</script>

<style lang="scss" scoped>
	.container{
		background: #19253e;
		padding-bottom:200rpx;
	}
	.user-wrapper{
		height: 370rpx;
		.nav_top_left{
			margin-top: 120rpx;;
			width:70%;
			float: left;
			margin-left: 15px;
			.top{
				float:left;
				font-size:36rpx;
				.nick_left{
					float:left;
					color:#fff;
					font-weight: 700;
				}
				.nick_right{
					color: #506efe;
					margin-top:2rpx;
					font-size: 22rpx;
					margin-left:10px;
					padding:1px 8px 1px 8px;
					border-radius: 5em;
					border:1px solid #506efe;
					float:left;
					
				}
				.vip{
					color: #f0c538;
					border:1px solid #f0c538 !important;
				}
				.cj{
					color: #fff;
					border:1px solid #fff !important;
				}
			}
			.bottom{
				width:100%;
				float:left;
				clear:both;
				color:#7A818E;
				font-size: 26rpx;
				margin-top: 25rpx;
			}
			
		}
		.nav_top_right{
			margin-top: 120rpx;;
			float:right;
			.avatar{
				width: 140rpx;
				height: 140rpx;
				border-radius: 50%;
			}
		}
		
		.role{
			margin-top: 10rpx;
			padding: 0 40rpx;
			height: 50rpx;
			line-height: 50rpx;
			border-radius: 50rpx;
			font-size: 24rpx;
			font-weight: bold;
			color: #5F83F4;
			background: rgba(255, 255, 255, .5);
			.vip{
				margin-right: 20rpx;
				width: 56rpx;
				height: 35rpx;
			}
		}
	}
	.guide{
		
		margin: -20rpx 20rpx 20rpx;
		padding:30rpx;
		border-radius: 16rpx;
		background: #475165;
		color:#7A818E;
		// box-shadow: 0 0 10rpx 0 rgba(118, 156, 255, 0.3);
		image{
			margin-bottom: 20rpx;
			width: 108rpx;
			height: 108rpx;
			border-radius: 0.5em;
		}
	}
	.order-wrapper{
		margin: 30rpx 20rpx 0;
		padding: 30rpx;
		border-radius: 16rpx;
		box-shadow: 0 0 10rpx 0 rgba(118, 156, 255, 0.3);
		.order-title{
			font-size: 30rpx;
			image{
				margin-left: 10rpx;
				width: 12rpx;
				height: 22rpx;
			}
		}
		.order-box{
			margin: 45rpx 30rpx 0;
			font-size: 24rpx;
			image{
				margin-bottom: 20rpx;
				width: 44rpx;
				height: 44rpx;
			}
		}
	}
	.lists{
		border-radius: 0.5em;
		margin: -20rpx 20rpx 20rpx;
		margin-bottom: 50px;
		margin-top:20rpx;
		box-shadow: 0 0 10rpx 0 rgba(118, 156, 255, 0.3);
		background: #475165;
		.list{
			color:rgba(255, 255, 255, 0.3);
			background: #475165;
			position: relative;
			padding: 30rpx 0;
			&:last-child{
				border-bottom: none;
			}
			.fa{
				font-weight: 500;
				margin-left:25rpx;
				color:#fff
			}
			.icon{
				margin-right: 16rpx;
				width: 48rpx;
				height: 48rpx;
			}
			.rightimg_str{
				position: absolute;
				right:40px;
				color:#fff;
				float:right;
			}
			.rightimg{
				width: 16rpx;
				height: 26rpx;
				margin-right: 16rpx;
			}
			button{
				position: absolute;
				top: 0;
				left: 0;
				right: 0;
				width: 100%;
				height: 100%;
				opacity: 0;
			}
		}
	}
	.share-wrapper{
		height: 600rpx;;
		z-index:9991;
		border-radius: 16rpx 16rpx 0 0;
		background: #0B204C;
	    border-radius: 0.8em;
		font-size: 30rpx;
		.tp{
			width: 100%;
			text-align: center;
			color: #fff;
			padding-top: 30rpx;;
			font-size: 32rpx;
			font-weight: 600;
		}
		.nav_tex{
			margin-top: 20rpx;
			width: 94%;
			margin-left: 3%;
			textarea{
				width: 100%;
				color: #fff;
				font-size: 24rpx;
				background: #293241;
				height: 160rpx;
				padding: 5px;
			}
		}
		
		.bom{
			float: left;
			margin-top: 20rpx;
			width: 94%;
			margin-left: 3%;
			.left{
				color: #fff;
				float: left;
			}
			.right{
				float: right;
				margin-right: 20rpx;
				color: #fff;
				width: 180rpx;
				text-align: center;
				height: 70rpx;
				line-height:70rpx;

			}
			
		}
		.bomt{
			
			float: left;
			margin-top: 20rpx;
			width: 70%;
			text-align: center;
			background: #5F83F4;
			border-radius: 0.2em;
			margin-left:15%;
			height: 80rpx;;
			line-height: 80rpx;;
			color: #fff;
			margin-bottom: 60rpx;
			border-radius: 5em;
		}
		
	}
	
	.service-wrapper{
		.service-box{
			padding: 60rpx 63rpx 70rpx;
			border-radius: 20rpx;
			background: #fff;
			.service{
				width: 235rpx;
				height: 214rpx;
			}
			.contact{
				margin-top: 45rpx;
				font-size: 36rpx;
			}
			.rightnow-box{
				margin-top: 60rpx;
				.rightnow{
					width: 420rpx;
					height: 88rpx;
					line-height: 88rpx;
					border-radius: 44rpx;
					text-align: center;
					font-size: 32rpx;
					color: #fff;
					background: #769CFF;
				}
				button{
					position: absolute;
					top: 0;
					left: 0;
					width: 100%;
					height: 100%;
					opacity: 0;
				}
			}
		}
		.dialogclose{
			margin-top: 60rpx;
			width: 48rpx;
			height: 48rpx;
		}
	}
	.uni-modal {  
	    background-color: #ff0000 !important; /* 红色背景 */  
	}
</style>
